SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
3-32
Using the INVOKE Directive
For further information, see Example 3-1 on page 3-35 and Example 3-2 on
page 3-36.
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
on all applicable columns when you run the SQL/MX C preprocessor. The general
syntax for using an embedded INVOKE directive within an SQL Declare Section in a
C program is:
EXEC SQL INVOKE table-or-view [AS structure-name];
struct structure-name structure-instance ;
For complete syntax, see the INVOKE Directive in the SQL/MX Reference Manual.
The struct declaration declares structure-instance to be a structure of the type
named structure-name.You must declare a variable of the struct type so that
you can use that variable in your C language statements.
If you do not specify the AS clause in the INVOKE statement, the default structure
name is the simple name of the table or view with the suffix _type appended. For
example: mytable_type.
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 C/C++ Preprocessor on page 15-8.
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.