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 17 of 18 Topic 1882 of 2101
Post > Topic >>

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

by ptomblin@[EMAIL PROTECTED] ("Paul Tomblin") Feb 20, 2008 at 09:03 AM

On Feb 20, 2008 8:50 AM, Heikki Lin****angas <heikki@[EMAIL PROTECTED]
>
wrote:
> Paul Tomblin wrote:
> > On Feb 20, 2008 8:14 AM, Heikki Lin****angas <heikki@[EMAIL PROTECTED]
>
w=
rote:
> >> Dave Cramer wrote:
> >>> I was going to say there are absolutely no situations where this is
n=
ot
> >>> true, however in your case autocommit or not it doesn't matter.
> >>> You have a single connection for the entire application and
asynchron=
ous
> >>> events using that connection. Autocommit or not it will not work
with
> >>> currval.
> >>>
> >>> In your case you must use nextval before doing the insert.
> >> Now you lost me. By asynchronous events, do you mean NOTIFY/LISTEN?
Wh=
at
> >> exactly is the scenario you're talking about?
> >
> > In my case, we're talking about a system that has dozens of Java
> > processes, many of which access the database.  Because the system used
> > to have autocommit on, one process could do the "insert nextval" and
> > commit, and then another process could do an "insert nextval" and
> > commit, and then the first process would do the "select currval" and
> > would probably get the wrong value.
>
>  From Dave's comment, I gather that those processes return the
> connection to the pool and grab a new one between the "insert nextval"
> and "select currval" steps? Yeah, I can see the problem in that case.

No, there is no connection pooling yet.  I'm working on that for the
release after this one.

=10Like I said, I was operating under the assumption that
nextval/currval was bound to the transaction, not to the connection.
I guess I was wrong.

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 ...(?,...


--=20
For my assured failures and derelictions I ask pardon beforehand of my
betters and my equals in my Calling here assembled, praying that in
the hour of my temptations, weakness and weariness, the memory of this
my Obligation and of the company before whom it was entered into, may
return to me to aid, comfort and restrain.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
 




 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:54:24 PST 2009.