Re: LAST_INSERT_ID equivalent

Поиск
Список
Период
Сортировка
От Erik Price
Тема Re: LAST_INSERT_ID equivalent
Дата
Msg-id 3EE8BBF0.7050306@ptc.com
обсуждение исходный текст
Ответ на Re: LAST_INSERT_ID equivalent  (Edmund Dengler <edmundd@eSentire.com>)
Ответы Re: LAST_INSERT_ID equivalent
Список pgsql-general

Edmund Dengler wrote:
> Greetings all!
>
> I believe
>    select currval('sequence_name');
> should satisfy your needs. Within a transaction it will stay the same.

Ed, thanks, this looks like what I was looking for --

however, I am concerned by your disclaimer.  Can you explain that a
little bit?  I read it to mean "if you try to use this technique within
a transaction where you are INSERTing a new record, it will not reflect
the new record's ID".  So then in order to determine the new record's ID
I would need to use

   SELECT CURRVAL('sequence_name') + 1;

within the transaction.


Thanks,

Erik


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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: LAST_INSERT_ID equivalent
Следующее
От: Sean Chittenden
Дата:
Сообщение: Re: Running two versions on same server