BEGIN TRANSACTION statement
Standards and
compatibility
Example
408
Caution
When calling a stored procedure, you should ensure that it operates
correctly under the required transaction mode.
$
For more information, see "CHAINED option" on page 175.
The current nesting level is held in the global variable @@trancount. The
@@trancount variable has a value of zero before the first BEGIN
TRANSACTION statement is executed, and only a COMMIT executed
when @@trancount is equal to one makes changes to the database
permanent.
A ROLLBACK statement without a transaction or savepoint name always
rolls back statements to the outermost BEGIN TRANSACTION (explicit or
implicit) statement, and cancels the entire transaction.
♦
Vendor extension
SQL/92
♦
Supported by Adaptive Server Enterprise.
Sybase
♦
The following batch reports successive values of
2, 1, and 0. The values are printed on the server window.
PRINT @@trancount
BEGIN TRANSACTION
PRINT @@trancount
BEGIN TRANSACTION
PRINT @@trancount
COMMIT
PRINT @@trancount
COMMIT
PRINT @@trancount
You should not rely on the value of@@trancount for more than keeping
track of the number of explicit BEGIN TRANSACTION statements that
have been issued.
When Adaptive Server Enterprise starts a transaction implicitly, the
@@trancount variable is set to 1. Adaptive Server Anywhere does not set the
@@trancount value to 1 when a transaction is started implicitly.
Consequently, the Adaptive Server Anywhere @@trancount variable has a
value of zero before any BEGIN TRANSACTION statement (even though
there is a current transaction), while in Adaptive Server Enterprise (in
chained mode) it has a value of 1.
@@trancount
as 0, 1,
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers