CREATE TYPE Examples | Teradata Vantage - CREATE TYPE Examples (Distinct Form) - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

Example: Creating a Distinct UDT for Euro Conversion

The following example creates a distinct UDT named euro based on the source data type DECIMAL(8,2):

    CREATE TYPE euro 
    AS DECIMAL(8, 2) 
    FINAL
    METHOD toUS()
    RETURNS us_dollar CAST FROM DECIMAL(8,2)
    LANGUAGE C
    DETERMINISTIC
    NO SQL
    RETURNS NULL ON NULL INPUT;
    …

Example: Creating a Distinct UDT for Dollar Conversion

The following example creates a distinct UDT named us_dollar based on the source data type DECIMAL(8,2):

    CREATE TYPE SYSUDTLIB.us_dollar 
    AS DECIMAL(8, 2) 
    FINAL
    METHOD toEuro()
    RETURNS euro CAST FROM DECIMAL(8,2)
    LANGUAGE C
    DETERMINISTIC
    NO SQL
    RETURNS NULL ON NULL INPUT;