Re: JDBC problem - Mailing list pgsql-interfaces

From Cedar Cox
Subject Re: JDBC problem
Date
Msg-id Pine.LNX.4.21.0008251145460.14895-100000@nanu.visionforisrael.com
Whole thread Raw
In response to Re: JDBC problem  (John McKown <jmckown@prodigy.net>)
Responses Re: JDBC problem  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Re: JDBC problem  (John McKown <jmckown@prodigy.net>)
List 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




pgsql-interfaces by date:

Previous
From: Peter Mount
Date:
Subject: RE: JDBC Patch
Next
From: Phil Davey
Date:
Subject: Access 2000 and PostgreSQL 6.5