17.05 - Nested BEGIN TRANSACTION/END TRANSACTION Pairs - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

When BEGIN TRANSACTION/ET pairs are nested, Vantage checks to ensure that each BEGIN TRANSACTION statement has a matching END TRANSACTION statement.

The outermost BEGIN TRANSACTION/END TRANSACTION pair defines the explicit transaction. The inner BEGIN TRANSACTION/END TRANSACTION pairs do not effect the transaction because Vantage does not support transaction nesting.

Any embedded multistatement requests and macro executions are considered part of the outermost BEGIN TRANSACTION/END TRANSACTION explicit transaction and are not considered to be implicit transactions in this context.

In a multistatement request, there can be no more than one BEGIN TRANSACTION statement, and if you do specify a BEGIN TRANSACTION statement, it must be the first statement in a request.

For example, the following series of requests is treated as one explicit transaction.

     BEGIN TRANSACTION;
      SELECT …;
      UPDATE …
      EXEC a(3,4);
        BEGIN TRANSACTION;
         UPDATE …;
         INSERT …
         ;INSERT …;
        END TRANSACTION;
      INSERT …;
     END TRANSACTION;

If an error occurs in the middle of a nested BEGIN TRANSACTION/END TRANSACTION, everything rolls back to the initial BEGIN TRANSACTION.