SQL/MP Programming Manual for COBOL85

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL85429326-004
2-13
Creating Host Variables Using the INVOKE Directive
Creating Host Variables Using the INVOKE
Directive
The INVOKE directive creates host variables that correspond to columns in an SQL
table or view. Each host variable is a COBOL data item with the same name as the
respective column in the table or view. If a column allows null values, INVOKE also
generates an indicator variable for the column.
To execute an INVOKE directive, a program’s process access ID (PAID) must have
read access to the invoked tables or views during COBOL compilation.
You code the INVOKE directive in a Declare Section. The COBOL85 compiler checks
the host variables generated by INVOKE for naming conflicts with other host variables
in the Declare Section, but not with COBOL reserved words. (If a name conflict occurs,
use SQLCI to generate the record description in a file, edit the names that conflict with
the reserved words, and copy the modified record description into your source
program. For more information, see Using INVOKE With SQLCI on page 2-23.)
Advantages of Using an INVOKE Directive
You can code host variables by creating a COBOL record definition that corresponds to
the SQL table. However, using an INVOKE directive to generate host variables has
these advantages:
Program independence—If you modify a table or view, the INVOKE directive
recreates the host variables to correspond to the new table or view when you
recompile the program. (You must, however, modify a program that refers to a
deleted column or must access a new column.)
TACL DEFINEs—The INVOKE directive accepts a class MAP DEFINE name for a
table or view name (but not for a record name).
Program performance—The INVOKE directive maps the SQL data types to the
corresponding COBOL data types; no data conversion is required at run time.
Program readability and maintenance—The INVOKE directive creates host
variables using the same names as column names in the table or view and
generates comments that show the table or view name and the time and date of
the definition.