17.05 - Example: Upsert Update - 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 a valid upsert UPDATE request.

     UPDATE sales
     SET itemcount = item_count + 1
     WHERE (item_nbr = 10
     AND    sale_date = '05/30/2000')
     ELSE INSERT
     INTO sales (10, '05/30/2000', 1);

After all of the rules have been validated, the row with item_nbr = 10 and sale_date = ‘05/30/2000’ gets updated.

A message indicates the successful update of one row.