Re: Getting Primary Key Value After Insert

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Getting Primary Key Value After Insert
Дата
Msg-id 20060709052502.68745.qmail@web31813.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: Getting Primary Key Value After Insert  ("Adam" <adam@spatialsystems.org>)
Ответы Re: Getting Primary Key Value After Insert  (Greg Stark <gsstark@mit.edu>)
Список pgsql-general
> I think I found the answer, you use the CURRVAL() function.
>
> Just to cover all the bases, consider this scenario in chronological order:
> 1.  You insert data and the primary key is set to 20.
> 2.  Someone else inserts data and the next key is set to 21.
> 3.  If you call currval() will it return 20?  I would think it does.

My understanding is that it will provided your are within a transaction. The following thread
showed a variation way to accomplish what you want.
http://archives.postgresql.org/pgsql-sql/2006-07/msg00095.php

Regards,

Richard Broersma Jr.

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

Предыдущее
От: "Adam"
Дата:
Сообщение: Re: Getting Primary Key Value After Insert
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: Is OpenFTS dead?