问题描述
说,我有一个名为JohnDoe = 0的全局int变量。我有一个执行许多操作的事务,包括将我的JohnDoe变量更新为5.现在,当事务成功时,所有值都被提交,JohnDoe现在变为5但是如果我的事务失败,所有值都会回滚,JohnDoe变为0.即使事务失败,我是否可以单独提交此变量的值?即使事务失败,我也希望将JohnDoe的值保留为5,尽管所有其他操作都应该回滚?有什么方法可以实现这个目的吗?
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 ?
推荐答案
这篇关于即使事务失败,也保留变量的特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!