17.05 - Example: Invoking an SQL UDF From a MERGE Request - 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)

This example shows how to invoke an SQL UDF named value_expression at several points within a MERGE request.

     MERGE INTO t1
     USING (SELECT a2, b2, c2
            FROM t2
            WHERE test.value_expression(b2, c2))
                  source_tbl(a2, b2, c2)
     ON a1 = source_tbl.a2 AND
        b1 = test.value_expression(source_tbl.b2, source_tbl.c2)
     WHEN MATCHED THEN
     UPDATE SET b1 = b2, c1 = test.value_expression(2,3)
     WHEN NOT MATCHED THEN
     INSERT (a2, test.value_expression(4,5), c2);