Russ wrote:
> Will there not be a race condition there?  If 2 servers run the same code at
> the same time, wouldn't' they be working with the same set of records?

Initially in the big select they can both get the same set of 
primary keys, but inside the loop they can not get the same records.


> I'm
> not really sure if and how "FOR UPDATE NOWAIT" solves that?

In the loop they wait for eachother because that select locks the 
record with the FOR UPDATE statement. The NOWAIT modifier is 
added so that the second select doesn't wait for the first one, 
but fails immediately. The failure is handled through the 
try/catch and the second thread moves on to the next record.

Try it :)

Jochem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231680
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to