Reputation: 712
Regarding the question, how to create a query to make sure only 1 transaction is working if multiple threads come in together?
UPDATE DPCM_BRANCH SET COUNTER = COUNTER+1 WHERE BRANCH=213546 and (SELECT COUNTER from dpcm_branch where counter = 122);
Above just a sample. I am sure above code return error.
I code with C# and Oracle SQL.
For the code above, I want to update COUNTER when the COUNTER is match with the latest COUNTER(122).
Can somebody help me??
Upvotes: 0
Views: 455
Reputation: 280
UPDATE DPCM_BRANCH SET COUNTER = COUNTER + 1
WHERE BRANCH = 213546 and counter = 122;
i'm not sure of your need but if the goal is to serialize the threads, the update can only occurs when it will be able to acquire the lock on the row, blocking the others threads until the holder does a commit or a rollback.
Upvotes: 2