A tricky question about transactions I have seem a code like the following:
code 1
ttsbegin;
code 2
ttsabort;
code 3
This code was done because in ‘code 2’ there is some calculations that affect the database but must be undone after that. For that reason a ttsabort comes later. But what happens is that this ttsabort also rollback some records that were updated before the ttsbegin:
If that way of work just a bad design or there is a way to insulate the effects of the ttsabort for only of the modifications done by ‘code 2’ ?
I would guess that code 1 is already in another transaction - ttsabort aborts all transactions, therefore even modifications done by code 1 are rolled back.
“There is some calculations that affect the database but must be undone after that” is definitely a bad design - refactor the calculation so it has no unwanted side effects.
Before ttsbegin at code 1, what is the TTS level? If its already 1 or more, then try to commit that transaction. Hope this makes sense.
And I agree with Martin that code needs refactoring. On another note other than some exceptional circumstances, calling ttsabort explicitly is not good idea.