Host Variable Declaration - Preprocessor2 for Embedded SQL

Teradata Preprocessor2 for Embedded SQL Programmer Guide

Product
Preprocessor2 for Embedded SQL
Release Number
15.00
Language
English (United States)
Last Update
2018-09-27
dita:id
B035-2446
lifecycle
previous
Product Category
Teradata Tools and Utilities

Host Variable Declaration

PP2 does not recognize every possible PL/I variable declaration as valid for use in a SQL statement. The following table is a list of the equivalent PL/I definitions for the Teradata Database.

For those types which have no direct PL/I declaration, the runtime processing allows returning data to one of the other types.

BEGIN DECLARE and END DECLARE are documented in SQL Stored Procedures and Embedded SQL (B035‑1148).

 

Table 15: PL/I Definitions for Teradata Database Data Types 

Data Type

Declaration

Notes

BYTE

No direct equivalent

Data can be returned to any valid host variable, however PP2 does not convert the data.

VARBYTE

No direct equivalent

CHAR(m)

DCL identifier
CHAR[(m)];

The integer m must be positive. If m is not specified, a default of CHAR(1) is used.

VARCHAR(m)

DCL identifier
CHAR[(m)] VAR[YING];

TIME

DCL identifier
CHAR[(m)]

The length of the char identifier must be 15.

TIMESTAMP

DCL identifier
CHAR [(m)]

The length of the char identifier must be 35.

DATE

DCL identifier
FIXED BIN[ARY] (m);

The integer m must be positive, such that 16 m 31.

The Teradata Database normally returns a DATE type field as integer.

It is possible to return the value in character string format, as long as the length of the receiving field is sufficient.

The DATEFORM=ANSIDATE format returns the DATE type field as CHAR (10).

DECIMAL(m,n)

DCL identifier
FIXED DEC[IMAL] [(m[,n])];

The precision and scale integers (m,n) must be positive such that m 15 and 0 n m. n set to zero is equivalent to specifying m alone. If no precision and scalar attributes are specified, a default of FIXED DEC(15) is used.

NUMERIC(m,n)

DCL identifier
FIXED DEC[IMAL][(m[,n])];

FLOAT*

DCL identifier

or

DCL identifier
FLOAT BIN[ARY] (m);
FLOAT DEC[IMAL] (n);

Integer m must be positive, such that 1 m 21; integer n must be positive such that 1 n 6.

REAL*

DCL identifier

or

DCL identifier
FLOAT BIN[ARY] (:m);
FLOAT DEC[IMAL](n);

DOUBLE PRECISION*

DCL identifier

or

DCL identifier
FLOAT BIN[ary](m);
FLOAT DEC[IMAL](n);

FLOAT**

DCL identifier

or

DCL identifier
FLOAT BIN[ARY] (m);
FLOAT DEC[IMAL] (n);

Integer m must be positive, such that 22 m 53; integer n must be positive such that 7 n 16.

REAL**

DCl identifier

or

DCL identifier
FLOAT BIN[ARY](m);
FLOAT DEC[IMAL](n);

DOUBLE PRECISION**

DCL identifier

or

DCL identifier
FLOAT BIN[ARY(m);
FLOAT DEC[IMAL](n);

BYTEINT

No direct equivalent

Data can be returned to any valid numeric format if the value fits into the field specified.

SMALLINT

DCL identifier
FIXED BIN[ARY] [(m[,n])];

Integer m must be positive, such that 1 m 15. n is normally zero for integer values, but if specified, PP2 ignores the value. If m is not specified, a default of FIXED BINARY(15) is used.

INTEGER

DCL identifier
FIXED BIN[ARY] (m[,n]);

Integer m must be positive, such that 16 m 31. n is normally zero for integer values, but if specified, PP2 ignores the value.

GRAPHIC(m)

DCL identifier
GRAPHIC[(m)];

The integer “m” is the number of graphic characters (not bytes) and must be positive. If “m” is not specified, a default of GRAPHIC(1) is used.

VARGRAPHIC(m)

DCL identifier
GRAPHIC[(m)] VAR[YING];

* single precision ** double precision