http://goo.gl/EmKxy0

Nested Transaction

NOTE: There must be at least one commit tran executed for each tran statement executed. But, regardless of how many begin tran/commit tran pairs appear to be nested in the code, there is only one transaction.

 

Example:

begin tran

change 1

begin  tran

change 2

commit tran

commit tran

In above pseudocode, there are two nested begin tran statement. Despite, the fact that it appears that there are two transactions (one inside another), there is actually only one open transaction. Thus, the transaction is active until the second commit tran statement is executed.

 

Example:

begin tran

change 1

begin tran

change 2

begin tran

change 3

commit tran

change 4

commit tran

change 5

rollback tran

In this example, none of the five changes would remain in the data after the rollback; again, although it looks like there are three levels of nesting, and it looks like changes 2,3,4, and 5 are fully bounded by begin/commit pairs, there is really only one transaction, and all work must complete in full or not at all. In fact, the transaction shown above is functionally identical to:

begin tran

change 1

change 2

change 3

change 4

change 5

rollback tran

Check the Sybase Wiki @ sybasewiki.com
  1. No comments yet.
  1. No trackbacks yet.