| From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
|---|---|
| To: | Scott Chapman <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:52:45 |
| Message-ID: | 20031109185245.GA28993@dcc.uchile.cl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Sun, Nov 09, 2003 at 10:26:51AM -0800, Scott Chapman wrote:
> 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 is concurrency-safe. That's exactly what sequences are for.
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"I call it GNU/Linux. Except the GNU/ is silent." (Ben Reiter)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Rajesh Kumar Mallah | 2003-11-09 20:06:20 | Problem in restoring data |
| Previous Message | Rajesh Kumar Mallah | 2003-11-09 18:39:37 | Converting SQL-ASCII encoding database to UNICODE |