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

From Bruno Wolff III
Subject Re: Ref to last INSERT on a table without OIDs?
Date
Msg-id 20030128170842.GB14694@wolff.to
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 Tue, Jan 28, 2003 at 14:25:32 -0000,
  Mark Cave-Ayland <mark.cave-ayland@webbased.co.uk> 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.

If you are trying to get the primary key of the last record inserted during
the same database session, then using serial for the type of the primary
key and the currval function is exactly what you want.

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Ref to last INSERT on a table without OIDs?
Next
From: Vivek Khera
Date:
Subject: Re: Vacuum verbose output?