Re: auto generated keys - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: auto generated keys
Date
Msg-id 6503.1048084063@sss.pgh.pa.us
Whole thread Raw
In response to auto generated keys  ("Paul Sorenson" <pauls@classware.com.au>)
List pgsql-jdbc
"Paul Sorenson" <pauls@classware.com.au> writes:
> I have a somewhat klunky hack in an application which immediately after
> inserting a row into a table with a "serial" for the primary key I do a
> select based on values I know to be unique (at least for the table in
> question).

You can use currval() to read the assigned sequence value after the
insertion.  The other common approach is to select the nextval()
explicitly and then insert it into the new row, instead of allowing
nextval() to be invoked by default.  See the FAQ ...

            regards, tom lane

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Follow-up OpenOffice and Postgres 7.3.2
Next
From: Adrian Klaver
Date:
Subject: Re: Follow-up OpenOffice and Postgres 7.3.2