Re: auto generated keys

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Paul Sorenson" <pauls(at)classware(dot)com(dot)au>
Cc: "postgresql jdbc" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: auto generated keys
Date: 2003-03-19 14:27:43
Message-ID: 6503.1048084063@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

"Paul Sorenson" <pauls(at)classware(dot)com(dot)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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Adrian Klaver 2003-03-19 14:39:09 Re: Follow-up OpenOffice and Postgres 7.3.2
Previous Message Dave Cramer 2003-03-19 10:01:43 Re: Follow-up OpenOffice and Postgres 7.3.2