17.10 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

Example: PERIOD(DATE) Data Type

The following CREATE TABLE statement defines a PERIOD(DATE) column with a default value set using a Period literal.

CREATE TABLE t1
(
      employee_id         INTEGER,
      employee_name       CHARACTER(15),
      employee_duration   PERIOD(DATE)
      DEFAULT PERIOD '(2005-02-03, 2006-02-03)'
);

Example: Period Parameter in a Java UDF

REPLACE FUNCTION PDT_UDF (P1 PERIOD(DATE), P2 PERIOD(DATE))
RETURNS PERIOD (DATE)
LANGUAGE JAVA
NO SQL
PARAMETER STYLE JAVA 
EXTERNAL NAME 'UDF_JAR:UserDefinedFunctions.pdt_udf';

public static java.sql.Struct pdt_udf(java.sql.Struct p1, java.sql.Struct p2) throws SQLException

Alternatively, you can define the function as follows:

REPLACE FUNCTION PDT_UDF (P1 PERIOD(DATE), P2 PERIOD(DATE))
RETURNS PERIOD (DATE)
LANGUAGE JAVA
NO SQL
PARAMETER STYLE JAVA 
EXTERNAL NAME 'UDF_JAR:UserDefinedFunctions.pdt_udf(java.sql.Struct, java.sql.Struct) returns java.sql.Struct';

public static java.sql.Struct pdt_udf(java.sql.Struct p1, java.sql.Struct p2) throws SQLException

Example: Period Parameter in a Java External Stored Procedure

REPLACE PROCEDURE PDT_XSP(IN P1 PERIOD(DATE), INOUT P2 PERIOD(DATE), OUT P3 PERIOD(DATE))
LANGUAGE JAVA
NO SQL
PARAMETER STYLE JAVA 
EXTERNAL NAME 'UDF_JAR:UserDefinedFunctions.pdt_xsp';
	
public static void pdt_xsp(java.sql.Struct p1, java.sql.Struct[] p2, java.sql.Struct[] p3) throws SQLException