16.10 - Example 1 – Teradata Temporal Syntax - Parallel Transporter

Teradata Parallel Transporter Reference

Product
Parallel Transporter
Release Number
16.10
Published
July 2017
Content Type
Programming Reference
Publication ID
B035-2436-077K
Language
English (United States)

Here is a Teradata Temporal example of the target temporal table definition with a VALIDTIME column named JOBDURATION:

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

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

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

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

The job must specify the DML statement(s) 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, :JOBDURATION);

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

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

The Teradata 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.