Re: [GENERAL] getting the value from nextval('sequencename')
Re: [GENERAL] getting the value from nextval('sequencename')
От:
Charles Tassell <ctassell@isn.net>
Дата:
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
>
>
>************
>
Re: [GENERAL] getting the value from nextval('sequencename')
От:
Vadim Mikheev <vadim@krs.ru>
Дата:
Charles Tassell wrote: > > If you are using transactions (as you probably should be) you can use ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > curval to get the last assigned value I believe. Something like: You can use currval anytime after nextval is called (at least once) in current database session. Vadim