SQL/MP Programming Manual for COBOL

Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for COBOL529758-003
10-13
Defining Storage for Input and Output Parameters
This example shows a version 315 SQLDA structure. For a description of version 1
and version 2 SQLDA structures, see Appendix D, Converting COBOL Programs.
01 sqlda-name.
05 EYE-CATCHER PIC X(2) VALUE "D1".
05 NUM-ENTRIES PIC S9(4) COMP VALUE sqlvar-count.
05 SQLVAR OCCURS sqlvar-count TIMES.
10 DATA-TYPE PIC S9(4) COMP.
10 DATA-LEN NATIVE-2.
10 PRECISION PIC S9(4) COMP.
10 NULL-INFO PIC S9(4) COMP.
10 VAR-PTR PIC S9(9) COMP VALUE -999999.
10 IND-PTR PIC S9(8) COMP VALUE -999999.
10 CPRL-PTR PIC S9(9) COMP VALUE -999999.
10 RESERVED PIC S9(9) COMP VALUE -1.
01 names-buffer PIC X( names-buffer-length ).
01 collations-buffer PIC X( collation-buffer-length ).
Table 10-3
lists the SQLDA DATA-TYPE values for each specific data type.
NULL-INFO For input parameters, NULL-INFO contains a negative integer if the
parameter permits null values.
For output parameters, NULL-INFO contains a negative integer if the
parameter can return a null value.
VAR-PTR The extended address of the actual data (value of input parameter or
database column). SQL/MP does not return VAL-PTR. Your program
must initialize it to point to the input and output data buffer.
IND-PTR The address of a flag that indicates whether a parameter or column is
actually null. For input parameters, your program initializes IND-PTR to -
1 if the user entered a null value. For output columns, SQL/MP initializes
the location referenced by IND-PTR to -1 if the column value was null. If
you program does not need to process null values, initialize IND-PTR to
an invalid address.
CPRL-PTR For input columns, CPRL-PTR is not set.
For output columns, CPRL-PTR contains the address of the collation
used by the column, if a collation was used. If a collation was not used
for the output column, CPRL-PTR contains a negative integer.
Table 10-3. SQLDA DATA-TYPE Values (page 1 of 3)
Value Type of Data
Fixed-Length Character Data Types (0 – 63)
0 Fixed-length single-byte character
1 Fixed-length single-byte character, upshifted
2 Fixed-length double-byte character
Table 10-2. SQLDA Structure Fields (page 2 of 2)
Field Name Description