Re: GetLastInsertID ? - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: GetLastInsertID ?
Date
Msg-id 20040101222112.GA7723@svana.org
Whole thread Raw
In response to Re: GetLastInsertID ?  (Mike Nolan <nolan@gw.tssi.com>)
Responses Re: GetLastInsertID ?
List pgsql-general
On Thu, Jan 01, 2004 at 03:37:46PM -0600, Mike Nolan wrote:
> > Use currval() after you have inserted.
>
> That will not necessarily tell you the last insertion, depending
> upon how many other users there are doing inserts.

Where do you get that impression? currval() refers to the last ID for the
session you are in. It's also FAQ question 4.15.3. Even better, if you
havn't used nextval() in your current session, currval() returns an error,
so you can't even get it wrong by accident.

http://www.postgresql.org/docs/faqs/FAQ.html#4.15.3

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> (... have gone from d-i being barely usable even by its developers
> anywhere, to being about 20% done. Sweet. And the last 80% usually takes
> 20% of the time, too, right?) -- Anthony Towns, debian-devel-announce

Attachment

pgsql-general by date:

Previous
From: Dave Cramer
Date:
Subject: Re: GetLastInsertID ?
Next
From: Martijn van Oosterhout
Date:
Subject: Re: why the need for is null?