SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in COBOL Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
4-23
Using the INVOKE Directive
•
Program readability and maintenance: The INVOKE statement creates host
variables using the same names as column names in the table or view.
Using the INVOKE Directive
To execute an INVOKE directive for a table or view, you must have SELECT privileges
to all applicable columns when you run the SQL/MX COBOL preprocessor.
The general syntax for using an embedded INVOKE directive within an SQL Declare
Section in a COBOL program is:
INVOKE table-or-view AS record
For complete syntax, see the INVOKE Directive in the SQL/MX Reference Manual.
INVOKE and Date-Time and Interval Host Variables (SQL/MX
Release 1.8 Applications)
SQL/MX Release 1.8 does not support SQL:1999 date-time host variables. In SQL/MX
Release 1.8 applications, you must declare a character array host variable for date-
time or interval data and use the CAST function for input or output from date-time or
interval columns.
If your SQL/MX Release 1.8 application uses INVOKE to create a date-time or interval
host variable and you plan to preprocess the application in SQL/MX Release 2.x, use
the -e preprocessor option. Otherwise, SQL/MX Release 2.x returns an error during
SQL compilation because the CAST function in the program is incompatible with the
SQL:1999 date-time host variables created by INVOKE in SQL/MX Release 2.x.
For more information, see Running the SQL/MX COBOL Preprocessor on page 16-9.
COBOL Record Descriptions Generated by INVOKE
The next examples show the correspondence between a table named
SQLCOB_DATA, that contains columns of various SQL data types, and the COBOL
record description generated by an INVOKE statement.
This INVOKE statement is coded in the COBOL source file in the SQL Declare
Section:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
EXEC SQL INVOKE sqlcob_data AS SQLCOB-TYPES-REC END-EXEC.
...
EXEC SQL END DECLARE SECTION END-EXEC.
The SQL/MX COBOL preprocessor generates the record description immediately after
the INVOKE statement in the preprocessed program code.
Note. This issue affects only SQL/MX Release 1.8 applications preprocessed by SQL/MX
Release 2.x. Previously compiled SQL/MX Release 1.8 applications continue to run correctly
without changes in SQL/MX Release 2.x.