Re: [GENERAL] getting the value from nextval('sequencename')

Поиск
Список
Период
Сортировка
От Charles Tassell
Тема Re: [GENERAL] getting the value from nextval('sequencename')
Дата
Msg-id 4.1.19990921014414.00c0c8f0@mailer.isn.net
обсуждение исходный текст
Список pgsql-general
If you are using transactions (as you probably should be) you can use
curval to get the last assigned value I believe.  Something like:

insert into table (field) values ('val');
select curval(seq_name);

I just wrote something similar in PHP that reads back the OID of the insert
and then does a select fieldname from table where oid = last_oid; which
also works well.  I believe there are ways to access the oid of your insert
from all of the languages with Postgres support.

At 05:40 PM 9/20/99, David Giffin wrote:
>
>Is there a way to tell what nextval('sequencename') returned? I have been
>doing a seperate query to get it. But in production this would lead to
>race conditions.
>
>Thanks,
>
>David
>
>
>************
>


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

Предыдущее
От: Nam Do
Дата:
Сообщение: ...
Следующее
От: Charles Tassell
Дата:
Сообщение: Re: [GENERAL] Case sensitivity