Re: LAST_INSERT_ID equivalent

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Erik Price <eprice(at)ptc(dot)com>
Cc: Ericson Smith <eric(at)did-it(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: LAST_INSERT_ID equivalent
Date: 2003-06-12 19:26:53
Message-ID: 20030612192653.GA5756@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jun 12, 2003 at 15:17:22 -0400,
Erik Price <eprice(at)ptc(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ericson Smith 2003-06-12 19:26:55 Re: LAST_INSERT_ID equivalent
Previous Message Steve Crawford 2003-06-12 19:19:49 Re: need a method to ping a running database