Trigger Support for Teradata Unity - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Detailed Topics

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
jpx1556733107962.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1184
lifecycle
previous
Product Category
Teradata Vantage™

Teradata Unity sends request-specific context information as part of a request that executes a trigger to enable Teradata Database to change the result of the executed trigger indirectly by substituting a value predefined by Teradata Unity for a non-deterministic result. Teradata Database makes this context information available to a trigger when it is executed from the default connection for the session.

Consider, for example, the following table and trigger definitions, where Teradata Unity overrides the RANDOM functions specified in the select lists of the triggered INSERT … SELECT requests specified in the trigger definitions.

     CREATE TABLE t1 (
       a INTEGER,
       b INTEGER)
     PRIMARY INDEX (a);

     CREATE TABLE t2 (
       a INTEGER,
       b INTEGER)
     PRIMARY INDEX (a);

     CREATE TABLE t3 (
       a INTEGER,
       b INTEGER)
     PRIMARY INDEX(a);

     CREATE TRIGGER trigt1
       AFTER INSERT ON t1 (
         INSERT t2
           SELECT a, RANDOM(200, 300)+1
           FROM t1;);

     CREATE TRIGGER trigt2
       AFTER INSERT ON t2 (
         INSERT t3
           SELECT a, RANDOM(200, 300)+1
           FROM t2;);