Example: MERGE and Target Columns - 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™

The following example fails because the INSERT specification of the WHEN NOT MATCHED clause specifies a column, z1, from the target table t1, which is an illegal operation.

     MERGE INTO t1
     USING (SELECT x2,y2, z3
            FROM t2, t3
            WHERE y2=10) AS s
       ON x1=y2 AND t4.x4=z2
     WHEN MATCHED THEN
       UPDATE SET z1=10
     WHEN NOT MATCHED THEN
       INSERT (x1,y1, z1) VALUES (y2, t1.z1, x2);