Example: MERGE and Target Columns - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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