Output Host Variables | VantageCloud Lake - Output Host Variables - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

When the results of a data returning SQL statement are received from the database, Preprocessor2 extracts the values and places them into the corresponding host output variables.

Valid Data Type Combinations

When you use an output main host variable to receive data from a FETCH or SELECT statement, only certain combinations of SELECT list element and host variable data types are allowed.

The valid combinations are shown in the following table. No other combinations are valid.

Most other combinations can be used by forcing the table column to change to a data type that is compatible with the data type host variable.

The data types listed in the Host Variable Data Type column are generic.

Database Column Data Type Host Variable Data Type
BYTE(m)

VARBYTE(m)

  • BYTE(n)
  • VARBYTE(n)
  • CHARACTER(n)
  • VARCHAR(n)
  • BYTEINT
  • SMALLINT
  • INTEGER
  • BIGINT
  • DECIMAL
  • NUMERIC
  • FLOAT
  • REAL
  • DOUBLE PRECISION
  • CHARACTER(n) CHARACTER SET GRAPHIC
  • VARCHAR(n) CHARACTER SET GRAPHIC
CHARACTER(m)

VARCHAR(m)

CHARACTER(n)

VARCHAR(n)

DATE (Teradata)
  • CHARACTER(n)
  • VARCHAR(n)
  • INTEGER
  • BIGINT
  • DECIMAL
  • NUMERIC
  • FLOAT
  • REAL
  • DOUBLE PRECISION
DATE (ANSI)

TIME

TIMESTAMP

INTERVAL

CHARACTER(n)
  • BYTEINT
  • SMALLINT
  • INTEGER
  • BIGINT
  • DECIMAL
  • NUMERIC
  • FLOAT
  • REAL
  • DOUBLE PRECISION
  • BYTEINT
  • SMALLINT
  • INTEGER
  • BIGINT
  • DECIMAL
  • NUMERIC
  • FLOAT
  • REAL
  • DOUBLE PRECISION
GRAPHIC(m)

VARGRAPHIC(m)

CHARACTER(n) CHARACTER SET GRAPHIC

VARCHAR(n) CHARACTER SET GRAPHIC

Assignment Rules

The following table explains assignment rules for output host variables.

Data Type Condition Description
BYTE m < n m bytes of data are moved to the host variable with (n - m) bytes of x’00’ added.
m = n m bytes of data are moved to the host variable.
m > n n bytes of data are moved to the host variable; the indicator, if used, is set to m; SQLWARN1 in the SQLCA is set to ‘W.’

m represents the length of the data.

n represents the length of the host variable.

BYTEINT, SMALLINT and INTEGER have implied lengths of 1, 2 and 4, respectively.

DECIMAL can have a length from 1 to 16 bytes.

FLOAT can be single (4 bytes) or double (8 bytes).

No data conversion is performed when a BYTE field is assigned to a host variable. The application is responsible for processing the value returned.

VARBYTE m ≤ n m bytes of data are moved to the host variable.
m > n n bytes of data are moved to the host variable; the indicator, if used, is set to m; SQLWARN1 in the SQLCA is set to ‘W.’

m represents the current length of the data;

n represents the maximum length of the host variable.

BYTEINT, SMALLINT and INTEGER have implied lengths of 1, 2 and 4, respectively.

DECIMAL can have a length from 1 to 16 bytes.

FLOAT can be single (4 bytes) or double (8 bytes).

No data conversion is performed when a BYTE field is assigned to a host variable. The application is responsible for processing the returned value.

CHARACTER m < n m bytes of data are moved to the host variable with (n - m) bytes of blanks (x’40’ in EBCDIC, x’20’ in ASCII environments) added.
m = n m bytes of data are moved to the host variable.
m >n n bytes of data are moved to the host variable; the indicator, if used, is set to m; SQLWARN1 in the SQLCA is set to ‘W.’

m represents the length of the data;

n represents the length of the host variable.

VARCHAR m<= n m bytes of data are moved to the host variable.
m > n n bytes of data are moved to the host variable; the indicator, if used, is set to m; SQLWARN1 in the SQLCA is set to ‘W.’

m represents the current length of the data; n represents the maximum length of the host variable.

DATE (Teradata)   into a CHARACTER field: If Teradata format is requested, n must be at least 8 bytes. All other formats require n to be at least 10 bytes. Remaining bytes are set to blanks (x’40’ in EBCDIC, x’20’ in ASCII environments). SQLCODE in the SQLCA is set to -304 if the host variable cannot contain the requested date format.
into a numeric field: The value must be representable in the type specified without losing leading digits. SQLCODE in the SQLCA is set to -304 if the host variable cannot contain the data.
DATE (ANSI)

TIME

TIMESTAMP

INTERVAL

  If Teradata format is requested, n must be at least 8 bytes. All other formats require n to be at least 10 bytes. Remaining bytes are set to blanks (x’40’ in EBCDIC, x’20’ in ASCII environments). SQLCODE in the SQLCA is set to -304 if the host variable cannot contain the requested date format.
  • BYTEINT
  • SMALLINT
  • INTEGER
  • BIGINT
  • DECIMAL
  • NUMERIC
  • FLOAT
  • REAL
  • DOUBLE PRECISION
  The value must be representable in the type specified without losing leading digits. SQLCODE in the SQLCA is set to -304 if the host variable cannot contain the data.