Partager via


TXNLEVEL( ) Function

Returns a numeric value indicating the current transaction level.

TXNLEVEL( )

Return Values

Numeric

Remarks

Use BEGIN TRANSACTION to create a transaction. Transactions are nested by issuing BEGIN TRANSACTION when another transaction is in progress. Transactions can be nested in this manner to five levels. Use TXNLEVEL( ) to determine the current transaction level.

TXNLEVEL( ) returns a value from 0 to 5. TXNLEVEL( ) returns 0 if a transaction is not in progress.

Example

In the following example, the customer table in the testdata database is opened. BEGIN TRANSACTION is issued to start a transaction, and TXNLEVEL( ) is used to display the transaction level (1). BEGIN TRANSACTION is issued again to start a nested transaction, and TXNLEVEL( ) displays 2 for the current transaction level.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer     && Open customer table
CLEAR

BEGIN TRANSACTION
   tLevel = ALLTRIM(STR(TXNLEVEL()))
   =MESSAGEBOX("Current Transaction: " + tLevel, 0, "Trasaction Level")
   BEGIN TRANSACTION
      tLevel = ALLTRIM(STR(TXNLEVEL()))
      =MESSAGEBOX("Current Transaction: " + tLevel, 0, ;
         "Trasaction Level")
   END TRANSACTION
END TRANSACTION

See Also

BEGIN TRANSACTION | END TRANSACTION | ROLLBACK