Click here to Skip to main content
15,904,638 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1. Begin T1 Transaction

2. Begin T2 Transaction

3. assign value 10 to cost column by T1. so cost=10

4. Update cost value to 20 by T2. so cost=20

5. Commit T2

6. rollback T1 ?? here cost value is 20 only not 10 how to solve this issue??????

What I have tried:

not tried any thing because I am not getting idea to solve this
Posted
Updated 25-Mar-17 21:09pm

1 solution

Look at this: Nesting Transactions[^]

Quote:
Committing inner transactions is ignored by the SQL Server Database Engine. The transaction is either committed or rolled back based on the action taken at the end of the outermost transaction. If the outer transaction is committed, the inner nested transactions are also committed. If the outer transaction is rolled back, then all inner transactions are also rolled back, regardless of whether or not the inner transactions were individually committed.


You need to manually check the transaction count and behave appropriately: Exception handling and nested transactions[^] should help.
 
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