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
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
vnq1596660420420.ditamap
dita:ditavalPath
hoy1596145193032.ditaval

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);