Nested BEGIN TRANSACTION/END TRANSACTION Pairs - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

When BEGIN TRANSACTION/ET pairs are nested, Teradata Database 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 Teradata Database 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.