Skip site navigation (1) Skip section navigation (2)

Re: INSERT and get ID

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Peter(dot)Zoche(at)materna(dot)de
Cc: Postgres JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: INSERT and get ID
Date: 2005-07-27 13:40:32
Message-ID: 1122471632.2837.79.camel@coppola.muc.ecircle.de (view raw or flat)
Thread:
Lists: pgsql-jdbc
It will be perfectly safe, as curval will return you the last value
created in the current session. So you can be sure it's your value
unless you use the same connection concurrently in different threads,
but in that case you would have bigger problems :-)

Cheers,
Csaba.

On Wed, 2005-07-27 at 15:29, Peter(dot)Zoche(at)materna(dot)de wrote:
> > You have to do a a "SELECT curval('myseq')" after the insert.
> 
> I had this in mind, too, but I am not sure if it is really safe if
> there are several inserts at the same time...
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend


In response to

pgsql-jdbc by date

Next:From: Roland WalterDate: 2005-07-27 13:53:01
Subject: Re: INSERT and get ID
Previous:From: Dave CramerDate: 2005-07-27 13:37:52
Subject: Re: INSERT and get ID

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group