Re: SQL-question: returning the id of an insert querry

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: scott_list(at)mischko(dot)com
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Andreas Fromm <Andreas(dot)Fromm(at)physik(dot)uni-erlangen(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: SQL-question: returning the id of an insert querry
Date: 2003-11-09 18:38:16
Message-ID: 87he1dz8tj.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Scott Chapman <scott_list(at)mischko(dot)com> writes:

> On Sunday 09 November 2003 03:13, Martijn van Oosterhout wrote:
> > After you've done the insert on the address table, you can use
> > currval('address_id_seq') (or equivalent) to get the ID. Ofcourse you
> > have to have used nextval() for the original insert.
>
> What if someone else inserts another address before I get the currval?
> I'm out of luck then, right?

No, currval() handles that--see the docs.

-Doug

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2003-11-09 18:39:37 Converting SQL-ASCII encoding database to UNICODE
Previous Message Scott Chapman 2003-11-09 18:26:51 Re: SQL-question: returning the id of an insert querry