Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Say, I have a global int variable called JohnDoe = 0. I have a transaction which performs many actions, including updating my JohnDoe variable to 5. Now, when the transaction succeeds, all the values are committed and JohnDoe now becomes 5. But if my transaction fails, all the values are rolled back and JohnDoe becomes 0. Is there any way I can commit the value of this variable alone even if the transaction fails ? Even if the transaction fails, I want to retain the value of JohnDoe as 5, though all other actions should be rolled back ? Is there any way I can accomplish this ?
Posted
Comments
johannesnestler 7-Jul-14 10:18am    
from your question it sounds like the JohnDoe variable should not take part in the transaction at all. Maybe you can describe your requriment for this?

1 solution

No - when a roll-back occurs, it is intended to restore the original state of the DB so that it is left in a manageable condition. It can't leave some bits changed and some not, because it doesn't know what bits are important to you and which aren't.

The best you can do is change your variable outside the transaction, or nest transactions so that you can roll back the inner one independently of the outer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900