Example 2 – ANSI Temporal Syntax - Parallel Transporter

Teradata® Parallel Transporter Reference

Product
Parallel Transporter
Release Number
17.10
Published
February 2022
Language
English (United States)
Last Update
2023-11-29
dita:mapPath
abr1608578396711.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
ogv1478610452101
Product Category
Teradata Tools and Utilities

Here is a ANSI Temporal example of the target temporal table definition with a derived period column JOBDURATION as a VALIDTIME column:

CREATE MULTISET TABLE TARGET_EMP_TABLE(
	EMP_ID      INTEGER,
	EMP_NAME    CHAR(30),
	EMP_DEPT    INTEGER,
	JOB_START   DATE NOT NULL,
	JOB_END     DATE NOT NULL,
	PERIOD FOR  JOBDURATION(JOB_START, JOB_END) AS VALIDTIME)
PRIMARY INDEX(EMP_ID);

Here is an example of the Teradata PT schema definition for the sample target ANSI temporal table definition:

DEFINE SCHEMA EMPLOYEE_SCHEMA
DESCRIPTION 'SAMPLE EMPLOYEE SCHEMA'
(
	EMP_ID       INTEGER,
	EMP_NAME     CHAR(30),
	EMP_DEPT     INTEGER,
	JOB_START    INTDATE,
	JOB_END      INTDATE USINGEXTENSION('PERIOD FOR JOBDURATION
							 (JOB_START, JOB_END) AS VALIDTIME')
);

In the sample Teradata PT schema definition, the USINGEXTENSION option is specified for the JOB_END column. The USINGEXTENSION option has a value of 'PERIOD FOR JOBDURATION (JOB_START, JOB_END) AS VALIDTIME'.

The job must specify the DML statements with a temporal qualifier (SEQUENCED, NONSEQUENCED, or CURRENT). Here is a sample DML statement with the SEQUENCED temporal qualifier:

SEQUENCED VALIDTIME INSERT INTO TARGET_EMP_TABLE (:EMP_ID, :EMP_NAME, :EMP_DEPT, :JOB_START, :JOB_END);

The Update operator will build the USING clause and send the USING clause to the database. Here is a sample USING clause:

USING EMP_ID(INTEGER),EMP_NAME(CHAR(30)), EMP_DEPT(INTEGER),
	JOB_START(DATE), JOB_END(DATE PERIOD FOR JOBDURATION(JOB_START,
	JOB_END) AS VALIDTIME)
SEQUENCED VALIDTIME INSERT INTO TARGET_EMP_TABLE (:EMP_ID,
	:EMP_NAME, :EMP_DEPT, :JOB_START, :JOB_END);

The database needs the USINGEXTENSION value to create the temporal NoPI staging table. During the Acquisition phase, data are populated into the staging table. After the Acquisition phase, the data are merged from the staging table to the temporal target table in the Application phase. After the Application phase, the staging table can be dropped.