TD_DataType - Parallel Transporter

Teradata Parallel Transporter Application Programming Interface

Product
Parallel Transporter
Release Number
15.00
Language
English (United States)
Last Update
2018-09-27
dita:id
B035-2516
lifecycle
previous
Product Category
Teradata Tools and Utilities

TD_DataType

For use with the AddColumn function in the schema object. The following table defines data type for each column in the schema. See SQL Data Types and Literals for detailed information on each data type including an explanation of precision and scale for the decimal type and length and precision for the period data type.

 

Table 6: Schema Object AddColumn Constants 

Constant

Data Type

TD_BIGINT

big integer

TD_BYTE

byte

TD_BYTEINT

byte integer

TD_CHAR

character

TD_DATE

date

TD_DATE_ANSI

ANSI date

TD_DECIMAL

decimal

TD_FLOAT

float

TD_GRAPHIC

graphic

TD_INTEGER

integer

TD_LONGVARCHAR

long variable length character

TD_LONGVARGRAPHIC

long variable length graphic

TD_NUMBER

fixed / floating point decimal

TD_PERIOD_DATE

period(date)

TD_PERIOD_TIME

period(time)

TD_PERIOD_TIME_TZ

period(time with time zone)

TD_PERIOD_TS

period(time stamp)

TD_PERIOD_TS_TZ

period(time stamp with time zone)

TD_SMALLINT

small integer

TD_VARBYTE

variable length byte

TD_VARCHAR

variable length character

TD_VARGRAPHIC

variable length graphic

On Specifying Data Types

Note the following when specifying data types:

  • The length of any CHAR or VARCHAR column should be an even number when using the UTF16 session character set. If the length for either one of these data types is an odd number when using the UTF16 session character set then an error will be returned by the Initiate method.
  • Do not use the TD_LONGVARCHAR data type when the server storage character set or the client session character set is a multibyte character set. KANJISJIS_OS, UTF8, and UTF16 are examples of multibyte character sets.
  • The PERIOD data types that support the date and time are in the form:
  • PERIOD(DATE)
  • PERIOD(TIME(n))
  • PERIOD(TIME(n) WITH TIME ZONE)
  • PERIOD(TIMESTAMP(n))
  • PERIOD(TIMESTAMP(n) WITH TIME ZONE)
  • The (n) corresponds to the precision of the column. The precision of these columns can be an integer from zero to six. Six is the default if no precision is specified. The PERIOD(DATE) data type has no precision.

  • PERIOD(DATE), PERIOD(TIME(n)) and PERIOD(TIME(n)) WITH TIME ZONE) are fixed length.
  • PERIOD(TIMESTAMP(n)) and PERIOD(TIMESTAMP(n)) WITH TIME ZONE) are variable length.
  • When using the TIME, TIMESTAMP, and INTERVAL data types, see Teradata Parallel Transporter Reference.
  • The NUMBER data type, compatible with Oracle's NUMBER data type, stores both fixed and floating point decimal numbers. NUMBER data type can be specified up to 38 digits. The following are the different possible syntax for the NUMBER data type:
  • NUMBER
  • NUMBER(*)
  • NUMBER(*,scale)
  • NUMBER(precision)
  • NUMBER(precision,scale)
  • The NUMBER data type is a variable length numeric column with the following external specification:

    <1-byte Length><2-bytes Scale><1 to 17 bytes 2's complement representation of the unscaled value in the client-appropriate endianness>

  • User applications should add the length of the NUMBER type as '18' bytes (recommended) while defining the schema. For example:
  • schema -> AddColumn("Number_dt", TD_NUMBER, 18, 5, 2); Length = 18, Precision = 5, Scale = 2.
  • For the Number(*) type, a precision of -128 should be added to the schema
  • Number(*, 4) is represented as schema -> AddColumn("Number_dt", TD_NUMBER, 18, -128, 4); Length = 18, Precision = -128, Scale = 4
     

    If NUMBER is...

    Precision Passed to Operator is...

    Scale Passed to Operator is...

    NUMBER

    -255

    -255

    NUMBER(*)

    -128

    -128

    NUMBER(*,scale)

    -128

    scale

    NUMBER(precision)

    precision

    -255

    NUMBER(precision,
    scale

    precision

    scale

  • If the precision is greater than 18, then the attribute TD_MAX_DECIMAL_DIGITS should be set.
  • In Teradata PT API, the Array data type, a Teradata UDT, is implemented as a VARCHAR. To implement the Array type in Teradata PT API:
  • Create ARRAY data type as follows:
  • CREATE TYPE pnum AS CHAR(10) ARRAY[2];
  • Create target table as follows:
  • Create table emp(Associate_Id integer, phone_nums pnum);
  • Add the column to the schema in Teradata PT API application:
  • schema -> AddColumn("phone_nums", TD_VARCHAR, 47);

    Note: The insert statement for the Array data type is:

    INSERT INTO target_table ( :Associate_Id, :phone_nums );