Re: Ref to last INSERT on a table without OIDs? - Mailing list pgsql-general

From Neil Conway
Subject Re: Ref to last INSERT on a table without OIDs?
Date
Msg-id 1043864169.519.11.camel@tokyo
Whole thread Raw
In response to Ref to last INSERT on a table without OIDs?  ("Mark Cave-Ayland" <mark.cave-ayland@webbased.co.uk>)
List pgsql-general
On Mon, 2003-01-27 at 10:59, Mark Cave-Ayland wrote:
> Hopefully just a quick one: how is it possible to obtain a reference to
> the last inserted record in a table which is created without oids? I
> would like to dump/restore some of our larger tables so they don't use
> oids, however I am concerned that simply getting the current PK sequence
> value after insertion within a transaction is not safe when many people
> are accessing the table/sequence at once? Can anyone clarify this? We're
> using the latest and greatest 7.3.1.

currval() is safe even in the face of concurrent insertions into the
table: it always returns the last value that the sequence generated in
the current session, regardless of whether any additional values have
been generated from the sequence by other clients.

See the docs on currval() for more information:

http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/functions-sequence.html

Cheers,

Neil
--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC




pgsql-general by date:

Previous
From: "Gordon A. Campbell"
Date:
Subject: unsubscribe
Next
From: Neil Conway
Date:
Subject: Re: psql command line question..