Re: GetLastInsertID ?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: GetLastInsertID ?
Дата
Msg-id 20040101222112.GA7723@svana.org
обсуждение исходный текст
Ответ на Re: GetLastInsertID ?  (Mike Nolan <nolan@gw.tssi.com>)
Ответы Re: GetLastInsertID ?
Список 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

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: GetLastInsertID ?
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: why the need for is null?