Consider running the below 2 3GLs concurrently,
Imagine db.update of both the 3GL is executed and we kept break point at the commit transaction
statement of both.
Now we first execute the commit.transaction()
statement of first 3GL.
And then when we execute the
commit.transaction of 2nd 3GL the cursor is taken to the db.retry.point()
and then again the new values of record is read and is updated and then committed
thereafter.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Doing db.update on the same record twice for
the same record selected with “for update” clause is ok.
But once you commit the changes inside the select for update on a record you cannot do db.update() on the same record. See the below example, where the system will fail in the second db.update statement. That's because the “for update” delayed lock mechanism will release the delayed lock on the current record inside selectdo once we do commit. Thus the next db.update will fail.
Again, having multiple commits inside a selectdo is
fine. Below code will work:-
Thank you for sharing valuable knowledge.
ReplyDelete