From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Mike Nolan <nolan(at)gw(dot)tssi(dot)com> |
Cc: | Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, Stephane Pinel <spinel(at)noos(dot)fr>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: GetLastInsertID ? |
Date: | 2004-01-01 22:21:12 |
Message-ID: | 20040101222112.GA7723@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)svana(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2004-01-01 22:25:22 | Re: why the need for is null? |
Previous Message | Dave Cramer | 2004-01-01 21:51:11 | Re: GetLastInsertID ? |