SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Static Rowsets
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
7-5
Using Rowset Arrays for Input
...
EXEC SQL END DECLARE SECTION;
...
EXEC SQL
SELECT first_name, last_name, salary
INTO :hva_first_name, :hva_last_name,
:hva_salary INDICATOR :hva_salary_indicator
FROM persnl.employee;
...
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 sqlstate pic x(5).
01 rs.
02 ROWSET[200] hvafirstname pic x(15).
02 ROWSET[200] hvalastname pic x(20).
02 ROWSET[200] hvasalary pic 9(8)v9(2) comp.
02 ROWSET[200] hvasalaryindicator pic 9(5).
EXEC SQL END DECLARE SECTION END-EXEC.
...
EXEC SQL
SELECT first_name, last_name, salary
INTO :hvafirstname, :hvalastname,
:hvasalary INDICATOR :hvasalaryindicator
FROM employee END-EXEC.
...
Using Rowset Arrays for Input
Use array host variables as input in the WHERE clause of SELECT, DELETE, or
UPDATE statements, the HAVING clause of a SELECT statement, the SET clause of
an UPDATE statement, and the VALUES clause of an INSERT statement.
Use rowset arrays for input to provide a looping mechanism equivalent to multiple
logical executions of the same SQL statement, once for each set of input values.
However, diagnostic information is returned only for the whole SQL statement and not
for each set of input values. When you use more than one array host variable as input
in an SQL statement, the input arrays might not all be of uniform size. In this situation,
the number of input values is equal to the size of the smallest input array. If you use
scalar host variables along with some rowset arrays as input, the scalar values are
duplicated as many times as the size of the smallest input array. This scenario is
semantically equivalent to replacing the scalar input host variable with an array (whose
size is the same as the smallest input array in that SQL statement), every element of
which has the same value as the scalar host variable.
When you use rowset arrays as input, check that all array elements up to the size of
the smallest input array have valid values. If not all elements of the input array are
used, specify the size of the input array size to be a smaller value by using the
ROWSET FOR INPUT SIZE syntax. See Specifying Size and Row ID for Rowset
Arrays on page 7-20.
COBOL