Example: Upsert Update Using a Period Bound Function - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-05
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™

Suppose you define the following row-partitioned table using the END Period bound function.

     CREATE SET TABLE testing.t33 (
       a INTEGER,
       b PERIOD(DATE),
       c INTEGER)
     PRIMARY INDEX (a)
     PARTITION BY CAST((END(b)) AS INTEGER);

This UPDATE upsert request inserts a new row into t33.

     UPDATE t33
      SET c = 1
         WHERE a = 20
         AND   END(b) = DATE '1901-02-25'
       ELSE INSERT INTO t33 (20, PERIOD(DATE '1901-02-24',
                             DATE '1901-02-25'), 1);