Checking the transaction nesting level with @@trancount  Checking the nesting level with @@nestlevel

Chapter 14: Using Batches and Control-of-Flow Language

Checking the transaction state with @@transtate

@@transtate contains the current state of a transaction after a statement executes in the current user session. However, unlike @@error, @@transtate does not get cleared for each batch. @@transtate may contain the values in Table 14-3:

Table 14-3: @@transtate values

Value

Meaning

0

Transaction in progress: an explicit or implicit transaction is in effect; the previous statement executed successfully.

1

Transaction succeeded: the transaction completed and committed its changes.

2

Statement aborted: the previous statement was aborted; no effect on the transaction.

3

Transaction aborted: the transaction aborted and rolled back any changes.

@@transtate only changes due to execution errors. Syntax and compile errors do not affect the value of @@transtate. See “Checking the state of transactions” for examples showing @@transtate in transactions.





Copyright © 2005. Sybase Inc. All rights reserved. Checking the nesting level with @@nestlevel

View this book as PDF