SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-23
Handling Parameters
reference the DATA-TYPE, DATA-LEN, and VAR-PTR fields in the SQLDA. In addition,
this program must initialize these fields:
EYE-CATCHER to point to the value D1 (for a version 2 or 300 SQLDA) or DA (for
a version 1 SQLDA).
VAR-PTR to point to the input or output data buffer. Because COBOL programs
cannot generate addresses, you must call a TAL procedure, SQLADDR, to
accomplish this task. SQLADDR takes the address of a host variable in Working
Storage and places the address in VAR-PTR. To call SQLADDR, use the format in
the next example. Its syntax is described in Section 5, SQL/MP System
Procedures.
IND-PTR to point to indicator variables, if any. If you are handling null values,
check NULL-INFO. If NULL-INFO is 0, do not allocate any memory. If NULL-INFO
is -1, allocate two bytes of memory for the indicator value and set IND-PTR to the
address of the indicator variable.
If the program does not process null values, set IND-PTR to an invalid address.
* For input data buffer (variable definitions appear in
* Example 10-1). INDEX is a loop counter--you are
* setting VAR-PTR for each input parameter:
ENTER TAL "SQLADDR"
USING P OF PARAMS(INDEX)
GIVING VAR-PTR OF SQLVAR OF IN-SQLDA(INDEX)
* For output data buffer (variable definitions appear in
* Example 10-3). INDEX is a loop counter--you are
* setting VAR-PTR for each output parameter:
ENTER TAL "SQLADDR"
USING C OF COLUMN(INDEX)
GIVING VAR-PTR OF SQLVAR OF OUT-SQLDA(INDEX)
Using the NULL-INFO and IND-PTR Fields
The DESCRIBE INPUT statement sets the NULL-INFO field depending on whether the
prepared SQL statement includes a null indicator and not whether the parameter
actually supports a null value. To determine if a parameter supports a null value, check
the NULLALLOWED column in the COLUMNS table for the catalog where the table is
registered.
The input and output SQLDA structures have two fields, NULL-INFO and IND-PTR,
that are used for handling null values:
NULL-INFO tells whether the input parameter or output variable can contain a null
value, based on whether the prepared statement includes an associated null
indicator parameter.