Example: Invoking an SQL UDF Within a Trigger Definition - Teradata Vantage - Analytics Database

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-22
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

This example invokes the SQL UDF common_value_expression from the WHEN clause of the definition of the row trigger trig_insert_after_update.

     CREATE TRIGGER trig_insert_after_update
       AFTER UPDATE OF b1 ON t1
       REFERENCING OLD AS OldRow NEW AS NewRow
     FOR EACH ROW
       WHEN (test.common_value_expression(OldRow.a1, NewRow.b1) >.10)
       INSERT INTO t2
       VALUES (NewRow.a1, NewRow.b1, NewRow.c1);

The next example invokes the SQL UDF common_value_expression in the triggered statement of the row trigger trig_insert.

     CREATE TRIGGER trig_insert 
       AFTER INSERT ON t1
       REFERENCING NEW AS n
     FOR EACH ROW (
       INSERT INTO t2 
       VALUES (n.a1, test.common_value_expression(n.b2, 1), n.c1); );