Talk About Network

Google





Data Bases > Pgsql Interfaces Jdbc > Re: Retrieving ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 18 Topic 1882 of 2101
Post > Topic >>

Re: Retrieving last InsertedID : INSERT... RETURNING safe ?

by gc@[EMAIL PROTECTED] (Guillaume Cottenceau) Feb 20, 2008 at 12:37 PM

"Heikki Lin****angas" <heikki 'at' enterprisedb.com> writes:

> spastor@[EMAIL PROTECTED]
 wrote:
>> Only one exception is regarding the best method to retrieve the last
>> inserted id (serial). There are many posts on this topic but i
>> couldn t find a definitive response. I am using postgresql version
>> 8.2.6 and jdbc  8.2_p505, i ve been experiencing INSERT statement
>> with RETURNING myID, using an executeQuery it works great, i
>> retrieve the proper value everytime at least  from the few tests i
>> have been doin  locally.
>> Is it THAT easy or could this method break somehow in a live
environement ?
>
> It is that easy, and that is a good way to do it.
>
> Alternatively, if you need to sup****t older PostgreSQL version for
> example, you could use a "SELECT currval('sequence')" query after the
> INSERT.

Well, that other solution is dangerous in case multiple inserts
to that table are done concurrently; a quite common usage pattern
with java web applications handling multiple HTTP requests with
concurrent java threads..

-- 
Guillaume Cottenceau

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match
 




 18 Posts in Topic:
Retrieving last InsertedID : INSERT... RETURNING safe ?
spastor@[EMAIL PROTECTED]  2008-02-20 10:44:37 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
heikki@[EMAIL PROTECTED]   2008-02-20 11:11:50 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
gc@[EMAIL PROTECTED] (Gu  2008-02-20 12:37:44 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
davec@[EMAIL PROTECTED]   2008-02-20 06:53:30 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
pg@[EMAIL PROTECTED] (Da  2008-02-20 06:54:20 
Re: Retrieving last InsertedID : INSERT... RETURNING safe
ptomblin@[EMAIL PROTECTED  2008-02-20 07:19:16 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
pg@[EMAIL PROTECTED] (Da  2008-02-20 07:28:18 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
heikki@[EMAIL PROTECTED]   2008-02-20 13:14:00 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
pg@[EMAIL PROTECTED] (Da  2008-02-20 08:32:42 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
heikki@[EMAIL PROTECTED]   2008-02-20 12:27:34 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
gc@[EMAIL PROTECTED] (Gu  2008-02-20 13:01:44 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
ptomblin@[EMAIL PROTECTED  2008-02-20 08:36:32 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
heikki@[EMAIL PROTECTED]   2008-02-20 13:50:06 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
pg@[EMAIL PROTECTED] (Da  2008-02-20 08:59:55 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
ptomblin@[EMAIL PROTECTED  2008-02-20 08:41:56 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
pg@[EMAIL PROTECTED] (Da  2008-02-20 09:02:35 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
ptomblin@[EMAIL PROTECTED  2008-02-20 09:03:14 
Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
heikki@[EMAIL PROTECTED]   2008-02-20 14:26:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 20:21:09 PST 2009.