15.00 - Tasks You Must Perform To Create A Distinct UDT - Teradata Database

Teradata Database SQL Data Definition Language Detailed Topics

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1184-015K
Language
English (United States)

Tasks You Must Perform To Create A Distinct UDT

Because distinct types are created with inherent transform, ordering, and casting capabilities (see “System‑Generated Default Functionalities For Distinct UDTs” on page 751), you need not take any action to create or activate any of these capabilities. These various functionalities are generated silently and activated at the time you submit the CREATE TYPE request.

This means that to create a minimal, fully functional distinct UDT, you need submit only a CREATE TYPE request. The following associated functionalities are then generated for you automatically by the system:

  • An ordering to enable two distinct UDTs to be compared
  • A transform group to enable the current distinct UDT to be passed between the client and Teradata Database.
  • A cast to enable casting, including implicit casting on assignment, from the underlying predefined data type to the distinct UDT and from the distinct UDT to the underlying predefined data type.
  • If your applications of the current distinct UDT require additional functionality, you can write instance methods in either the C or C++ languages, and then submit CREATE INSTANCE METHOD statements to declare any SQL-invoked methods to be associated with their distinct UDT.

    Additionally, if you do not want to use the system‑generated semantics for a distinct UDT, you can define your own unique ordering, transform, and casting functionalities.

    To do this, you must perform the following high‑level general procedure.

    1 Drop the system‑generated casts, orderings, or transforms you want to replace using the appropriate SQL DROP statements from the following list:

  • DROP CAST (see “DROP CAST” on page 793).
  • DROP ORDERING (see “DROP ORDERING” on page 806).
  • DROP TRANSFORM (see “DROP TRANSFORM” on page 812).
  • 2 Code the appropriate external routines in either C or C++ (see SQL External Routine Programming)

    3 Create new casts, ordering, or transforms for the UDT using the appropriate SQL CREATE statements from the following list:

  • CREATE CAST (see “CREATE CAST/ REPLACE CAST” on page 212).
  • CREATE ORDERING (see “CREATE ORDERING/ REPLACE ORDERING” on page 416).
  • CREATE TRANSFORM (see “CREATE TRANSFORM/ REPLACE TRANSFORM” on page 694).