Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [JDBC] Retrieving last InsertedID : INSERT... RETURNING safe ?

From: Heikki Linnakangas <heikki(at)enterprisedb.com>
Date: Wed Feb 20 2008 - 09:26:05 EST


Paul Tomblin wrote:
> Be that as it may, I still don't see what you gain by doing
> insert ... (nextval('idseq'),...
> select currval('idseq');
> when you could do
> select nextval('idseq');
> insert ...(?,...

Oh, sure, there's not gain either way. Select nextval + insert works just as well.

Theoretically, you could "pipeline" the "INSERT nextval" + "SELECT currval" method, by sending both commands at once and only then block and wait for response, saving one round-trip to the server. You could do that with a batch statement, I think, or by single executeQuery("INSERT ... ; SELECT currval(...)"). But if you don't do that, there's no difference.

-- 
   Heikki Linnakangas
   EnterpriseDB   
http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               
http://www.postgresql.org/docs/faq
Received on Wed Feb 20 09:28:43 2008

This archive was generated by hypermail 2.1.8 : Wed Jun 18 2008 - 23:45:14 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library