DF_TRAN_COUNT
See Also: Get_Attribute, Set_Attribute, Begin_Transaction, End_Transaction, Abort_Transaction, Lock, Reread, Unlock
Indicates the number of nested transactions.
Type
Numeric, temporary
Access
Read only
Values
Positive integer
Remarks
In DataFlex, it is allowed to nest transactions. When this occurs, the outer transaction logic will execute, and DF_TRAN_COUNT is incremented. The nested transactions will merely increment the DF_TRAN_COUNT attribute when started and decrement it again when they finish. When the outer transaction finishes, the transaction logic will execute, and DF_TRAN_COUNT will be decremented. An execution of Abort_Transaction will set DF_TRAN_COUNT to 0 (zero), as will the abortion of a transaction due to an error condition.
DataFlex supports two types of transactions:
- Explicit Transaction: Started by the Begin_Transaction command and ended by the End_Transaction command.
- Implicit Transaction: Started via the Lock or Reread command and ended via the Unlock command.
Example
The following sample procedure demonstrates the transaction count when nesting transactions:
Procedure DemoTranCount
Integer iTranCount
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Begin_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Begin_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Begin_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Begin_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
End_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
End_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
End_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
End_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Begin_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Lock
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Reread
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Lock
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Unlock
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Unlock
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
Unlock
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
End_Transaction
Get_Attribute DF_TRAN_COUNT To iTranCount
Showln "Current transaction count: " iTranCount
End_Procedure // DemoTranCount
The output of this procedure will show a transaction count incrementing up to 4, then decrementing to 0, incrementing again up to 4, and decrementing again to 0.