Re: Value of serial data type after insert. - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Value of serial data type after insert.
Date
Msg-id 20041114052927.GA91606@winnie.fuhr.org
Whole thread Raw
In response to Value of serial data type after insert.  (Ernest Kim <krazykid@cs.bu.edu>)
List pgsql-general
On Wed, Nov 10, 2004 at 02:34:22PM -0500, Ernest Kim wrote:

> I was wondering if there was a way to get the value of serial data
> type after an insert.

Use currval():

http://www.postgresql.org/docs/7.4/static/functions-sequence.html

Race condtions aren't a problem:

"Notice that because this is returning a session-local value, it
gives a predictable answer even if other sessions are executing
nextval meanwhile."

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: Woodchuck Bill
Date:
Subject: Re: I'm about to release the next postgresql RFD. Comments
Next
From: TJ Talluto
Date:
Subject: Re: need simple strategy for universal extension table