Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


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

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

by pg@[EMAIL PROTECTED] (Dave Cramer) Feb 20, 2008 at 08:32 AM

Heikki


On 20-Feb-08, at 8:14 AM, Heikki Lin****angas wrote:

> Dave Cramer wrote:
>> On 20-Feb-08, at 7:19 AM, Paul Tomblin wrote:
>>> Dave Cramer wrote:
>>>>> 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..
>>>>>
>>>> No it is not dangerous. It is the right way to do it. There is  
>>>> absolutely no danger in using currval in this manner.
>>>
>>> Unless you have autocommit on.
>>>
>> I was going to say there are absolutely no situations where this is  
>> not true, however in your case autocommit or not it doesn't matter.
>> You have a single connection for the entire application and  
>> asynchronous 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?  
> What exactly is the scenario you're talking about?
>
> One problematic scenario for nextval+currval is an INSERT trigger  
> that calls nextval() behind your back, but you can fool any method  
> with a trigger if you really want to.
>
As far as I can tall Paul has inherited an application which uses a  
single connection for all database operations, and is a swing app  
which has callbacks which do the following

Callback code

	grab the global connection object
	create a statement
	do something	
	close statement

in this scenario, since currval has connection scope if two callbacks  
are called at the same time, only one will have the right answer .

Paul am I correct in my assumptions above ?


Dave
>

---------------------------(end of broadcast)---------------------------
TIP 7: You can help sup****t the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate
 




 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
tan12V112 Sat Sep 6 15:31:09 CDT 2008.