SQL Programming Manual for TAL

Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL527887-001
2-20
Creating Host Variables With the INVOKE Directive
Creating Host Variables With the INVOKE Directive
You can use the INVOKE directive in a Declare Section to create host variables that
correspond to the columns in an SQL table. INVOKE converts the column names to
TAL identifiers and writes a TAL data description for each column. If a column allows a
null value, INVOKE also generates an indicator variable for the column.
Table 2-4 shows the override data type mapping used by the INVOKE directive.
This example shows the TAL compiler output for a table that contains columns of the
TAL data types. This example includes the INVOKE directive as it appears in the
source program, the CREATE TABLE statement that defines the table, and the
generated structure type. The table contains columns of all SQL data types. INVOKE
generates override data type mapping for some data types.
Caution. If you use INVOKE and later change data types in your SQL tables, you must ensure
that numeric constants in the TAL program also change to reflect the new data types;
otherwise, the program will not compile. For example, if host variable :PARTNUM is originally
defined as an integer (INT), the test::
IF partnum > 1000
is valid. However, if the :PARTNUM column is changed to INVOKE statement with the data
type INT(32), the test must be:
IF partnum > 1000D
Table 2-4. INVOKE Directive Override Data Type Mapping
SQL Data Type Host Variable Description Generated by the INVOKE Directive
SMALLINT
UNSIGNED
INT name / SMALLINT UNSIGNED /
INTEGER
UNSIGNED
INT(32) name / INTEGER UNSIGNED /
NUMERIC (1 - 4,
s)
UNSIGNED INT name / SMALLINT UNSIGNED /
NUMERIC (5 - 9,
s)6
UNSIGNED INT(32) name / INTEGER UNSIGNED /
DECIMAL(1) STRING name / DECIMAL(1) /
DECIMAL(1) UNSIGNED STRING name / DECIMAL(1) UNSIGNED /
DECIMAL (n)STRING name [0 : n - 1] / DECIMAL(n) /
DECIMAL (n) UNSIGNED STRING name [0 : n - 1] / DECIMAL (n) UNSIGNED /
name is the name of the host variable.
n is a positive integer that represents the length.
s is a positive integer that represents the scale of the number.