Transactions

MHotovec

Member
Myself and the big guns (my bosses) are confused about something we have happening here.
We are under the (apparently incorrect) belief that a 'do transaction' loop will prevent an 'undo' being done to a table.
We have a piece of code that basically does the following;

For each table no-lock
break by table.field:

if first-of table.field
then run p-procedure.

do more stuff which includes exclusive locks and updates on other tables.
end.

procedure p-procedure:
do transaction:
find table2 exclusive-lock.
variable = table2.field.
table2.field = table2.field + 1.
end.
end.

If the users session is killed for any reason (power outage, kicked cord, disgruntled user turning off computer - whatever) while the user is still in the 'do stuff' section of the for-each loop then table2.field suffers and 'undo' which takes it back to what table2.field was originally. Under NO circumstances do we want that field to roll back. And we're all under the impression that the 'do transaction' statement will handle that. Obviously we're wrong. Any suggestions on what to do to correct this?

Thanks, Mark.
 

laa

Member
The problem here is the section of code where you do more stuff which includes exclusive locks and updates on other tables. By doing these updates outside of the transaction block that you are setting you are forcing Progress to expand its transaction block to include the entire for each.

The being said, if you want your transaction block to always be done even if the for each in undone, then you should put a transaction block around your section of code that does more stuff which includes exclusive locks and updates on other tables. In that way Progress will see two independent transaction blocks and will only undo the second one if the for each is undone.

Hope this makes sense.

Anne.
 

MHotovec

Member
Queen of the world?!?
And yet you have time to help me with my piddly problem, I'm honored! :)

Your solution is simple, elegant and falls into the realm of "well YEAH, why didn't I think of that". Thank you muchly, I'm off to modify my code accordingly!

Mark
 
Top