Re: Value of serial data type after insert.

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Value of serial data type after insert.
Дата
Msg-id 20041114052927.GA91606@winnie.fuhr.org
обсуждение исходный текст
Ответ на Value of serial data type after insert.  (Ernest Kim <krazykid@cs.bu.edu>)
Список 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 по дате отправления:

Предыдущее
От: Woodchuck Bill
Дата:
Сообщение: Re: I'm about to release the next postgresql RFD. Comments
Следующее
От: TJ Talluto
Дата:
Сообщение: Re: need simple strategy for universal extension table