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.