Re: Value of serial data type after insert.

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Ernest Kim <krazykid(at)cs(dot)bu(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Value of serial data type after insert.
Date: 2004-11-14 05:29:27
Message-ID: 20041114052927.GA91606@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2004-11-14 05:40:10 Re: How many secondary databases can I create?
Previous Message Michael Fuhr 2004-11-14 05:01:47 Re: Large database