This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
To: James Maes <jmaes@sportingnews.com>
From: "Brett W. McCoy" <bmccoy@chapelperilous.net>
Subject: Re: Postgresql 7.0.3
Date: Mon, 15 Jan 2001 01:20:19 -0500 (EST)
On Sun, 14 Jan 2001, James Maes wrote:
> Is there anyway to return the result of a insert to a serial column in
> Postgres or DBD:Pg?
Yes, "SELECT currval('seq_name')" will give you the last value used in a
sequence, (implicitly created by the SERIAL declaration), where the
sequence is the column name with _seq appended.
((Does this work if multiple processes are doing inserts?
Sounds like a race-condition, but maybe some sort of
transaction magic covers the problem. Ask on PGSQL list
some time? -- doom ))
===
To: "James Maes" <jmaes@sportingnews.com>, "DBI"
<dbi-users@isc.org>
From: "Michael Mayo" <michael-a-mayo@worldnet.att.net>
Subject: Re: Postgresql 7.0.3
Date: Mon, 15 Jan 2001 00:01:57 -0500
----- Original Message -----
From: "James Maes" <jmaes@sportingnews.com>
> Is there anyway to return the result of a insert to a serial column in
> Postgres or DBD:Pg?
Nope. You have to do SELECT nextval('sequence_name') then
use the result in your future queries.
===