15.10 - Conversion Rules - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

prodname
Preprocessor2 for Embedded SQL
vrm_release
15.10
category
Programming Reference
featnum
B035-2446-035K
  • Numeric values might not be returned to character or byte strings. The only exception to this is DATE.
  • DATE fields can be returned to character fields (not byte) if the length of the field can hold the conversion type requested by the DATE option. See “DATE(D|E|I|J|U) -d D|E|I|J|U” on page 71.

  • BYTE and VARBYTE strings can be returned to any valid host variable type.
  • The byte string is moved one byte at a time for the length of the receiving variable.

    No data conversion is performed and the application is responsible for handling the returned data.

  • CHAR and VARCHAR strings are returned only to CHAR, VARCHAR or character string type variables.
  • A CHAR host variable is defined as a one character char type (that is, char var1).

    VARCHAR is defined as a structure having a two byte length field and a character array data field.

    A character string is defined as an array of two or more elements of char type (that is, char var1[2]), which is terminated by a terminating null character ('\0').

  • DATE values can be returned to a numeric type (DECIMAL, NUMERIC, INTEGER, FLOAT, REAL, DOUBLE PRECISION), as long as the value is representable in the receiving type.
  • DATE in its natural format (such as a DESCRIBE for a dynamic request) is equivalent to INTEGER.

    DATE can also be returned to a CHAR, VARCHAR or character string field, provided the length of the receiving field can hold the format requested.

    The character variable must be at least length 8 to receive the date in any of the allowable formats. The character string type variable must be at least length 9 (date plus the terminating null character of '\0') to receive the data.

  • DECIMAL values can be returned to any numeric type (DECIMAL, NUMERIC, INTEGER, SMALLINT, BYTEINT, FLOAT, REAL, DOUBLE PRECISION), as long as the value is representable in the receiving type.
  • C does not provide a natural DECIMAL data type. Memory can be allocated, however, to hold the value and the SQLDA set to reflect a DECIMAL type host variable. The application then is responsible for manipulation of the data.

  • BYTEINT, SMALLINT and INTEGER values can be returned to any numeric type (DECIMAL, NUMERIC, INTEGER, SMALLINT, BYTEINT, FLOAT, REAL, DOUBLE PRECISION), as long as the value is representable in the receiving type.
  • FLOAT values can be returned to any numeric type (DECIMAL, NUMERIC, INTEGER, SMALLINT, BYTEINT, FLOAT, REAL, DOUBLE PRECISION), as long as the value is representable in the receiving type.
  • The Teradata SQL FLOAT, REAL and DOUBLE PRECISION types are equivalent to a DOUBLE PRECISION FLOAT.

    PP2 recognizes both SINGLE and DOUBLE PRECISION FLOAT host variable types.

    Fractional portions of the value can be lost in conversion to a type other than DOUBLE PRECISION FLOAT.

    Note: No host GRAPHIC-type variable declaration for the C language is recognized by PP2.