Re: LAST_INSERT_ID equivalent

Bruno Wolff III <bruno@wolff.to>

From: Bruno Wolff III <bruno@wolff.to>
To: Erik Price <eprice@ptc.com>
Cc: Ericson Smith <eric@did-it.com>, pgsql-general@postgresql.org
Date: 2003-06-12T19:26:53Z
Lists: pgsql-general
On Thu, Jun 12, 2003 at 15:17:22 -0400,
  Erik Price <eprice@ptc.com> wrote:
> 
> So you're saying that you perform a pre-query to fetch the nextval, then 
> you include that in your query where you perform the INSERT?  I see. 
> Since this is all part of the same transaction, the nextval value won't 
> overwrite another simultaneous INSERT, I assume.  This seems like a good 
> way to do it too.  I don't mind the holes in the sequence, but wouldn't 
> this INSERT cause the sequence to increment the primary key yet again?

If you do things that way you specify a value for the serial column
rather than let it default to using nextval.