Re: [GENERAL] getting the value from nextval('sequencename') - Mailing list pgsql-general

From Charles Tassell
Subject Re: [GENERAL] getting the value from nextval('sequencename')
Date
Msg-id 4.1.19990921014414.00c0c8f0@mailer.isn.net
Whole thread Raw
List 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 by date:

Previous
From: Nam Do
Date:
Subject: ...
Next
From: Charles Tassell
Date:
Subject: Re: [GENERAL] Case sensitivity