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. If this happens 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 abortion of a transaction by an error condition.

DataFlex supports two types of transactions: Explicit and Implicit. An implicit transaction is a transaction that is started via the Lock or Reread command and ended via the Unlock command. An explicit transaction is started by the Begin_Transaction command and ended by the End_Transaction command.

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 sample procedure above shows the transaction count when nesting transactions. 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.