From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Mark Cave-Ayland <mark(dot)cave-ayland(at)webbased(dot)co(dot)uk> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Ref to last INSERT on a table without OIDs? |
Date: | 2003-01-28 17:08:42 |
Message-ID: | 20030128170842.GB14694@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Jan 28, 2003 at 14:25:32 -0000,
Mark Cave-Ayland <mark(dot)cave-ayland(at)webbased(dot)co(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Charles Tassell | 2003-01-28 17:27:59 | Re: stopping access to a database |
Previous Message | Vivek Khera | 2003-01-28 17:02:44 | Re: DBD::Pg & DBD::PgPP Cpan question |