Re: JDBC problem

From: Cedar Cox <cedarc(at)visionforisrael(dot)com>
To: John McKown <jmckown(at)prodigy(dot)net>
Cc: BogdanKRomski <b(dot)kromski(at)gaschka(dot)pl>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: JDBC problem
Date: 2000-08-25 08:49:32
Message-ID: Pine.LNX.4.21.0008251145460.14895-100000@nanu.visionforisrael.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Thu, 24 Aug 2000, John McKown wrote:

> The syntax that I've seen is:
>
> insert into KEY_ITEM (key_item_id,keyname) values
> (select max(key_item_id)+1,'?' FROM KEY_ITEM);
>
> Just out of curiousity, why not make key_item_id a SERIAL field? That way,
> if you don't specify a value, it gets the next value from the associated
> sequence.

I was going to ask you to explain SERIAL but the documentation makes it
fairly clear.. basically just the next value, yes? Simply setting the
field type to SERIAL seems to be the same as the MS Access 'autonumber'
field. Is this correct?

One detail that seems to have an advantage over the MAX+1 method is that
in the case of adding a new record, deleting it, then adding another new
record the ID will not be reused (correct?).

Question: What happens when transactions enter the picture? Will you get
duplicate values, or holes, or does it work just fine?

-Cedar

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Phil Davey 2000-08-25 10:43:34 Access 2000 and PostgreSQL 6.5
Previous Message Peter Mount 2000-08-25 08:36:49 RE: JDBC Patch