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

Static Rowsets
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
7-4
Specifying Rowset Arrays
The total rowset size should not exceed the physical memory of the client
computer to avoid fragmentation while accessing a rowset array.
The rowset size should not be less than the number of rows that need to be
accessed simultaneously. For example, a screen-based application should use a
rowset size that is a multiple of the number of rows displayed on the screen.
Specifying Rowset Arrays
After you declare a host variable array that is a part of a rowset, use this syntax to
specify it within an embedded SQL statement.
array-name
is the host variable array name. It can be any valid host language identifier with a
data type that corresponds to an SQL data type. You must precede array-name
with a colon (:) within an SQL statement.
INDICATOR
is an optional keyword that precedes indicator-array-name.
indicator-array-name
is an indicator variable array of exact numeric data type. This data type is short in
C or PIC 9(4)comp in COBOL. You must precede indicator-array-name
with a colon (:) in an SQL statement.
If data returned in the host variable array for a particular row and column is null,
the corresponding indicator variable is set to –1. If character data returned is
truncated, the indicator variable is set to the length of the string in the database.
Otherwise, the value of the indicator variable is zero. To insert null into the
database, set the indicator variable to a value less than zero for a particular row
and column in the corresponding host variable array. For inserting nonnull values,
the corresponding indicator variable must be set to zero. This last rule is also true
for all input arrays (for example, those used in WHERE and SET clauses). You
generate a run-time error if you specify a positive value in an indicator for input.
Example
This example retrieves three columns of, at most, 200 rows of a table. The salary
column can be null, and the salary array is followed by an indicator array:
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
ROWSET [200] char hva_first_name[16];
ROWSET [200] char hva_last_name[21];
ROWSET [200] unsigned NUMERIC (8,2) hva_salary;
ROWSET [200] short hva_salary_indicator;
:array-name [[INDICATOR] :indicator-array-name]
C