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-10
Selecting Rows Into Rowset Arrays
 INTO :hva_projcode, :hva_projdesc, :hva_start_date 
 FROM persnl.project 
 WHERE start_date <= DATE '1998-12-01'; 
...
EXEC SQL GET DIAGNOSTICS :numrows = ROW_COUNT;
...
for (i = 0; i < numrows; i++) { 
 hva_projdesc[i][18] = '\0'; 
 hva_start_date[i][10] = '\0'; 
 printf("\nProject: %hu, %s, Started: %s", 
 hva_projcode[i], hva_projdesc[i], hva_start_date[i]); 
 ...
 /* Process the row in some way. */
 ....
} 
...
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
 01 sqlstate pic x(5).
 01 numrows pic 9(9) comp.
 01 rs.
 02 ROWSET[200] hvaprojcode pic 9(4) comp.
 02 ROWSET[200] hvaprojdesc pic x(18).
 02 ROWSET[200] hvastartdate DATE.
EXEC SQL END DECLARE SECTION END-EXEC.
 01 i pic s9(4) comp.
 ...
EXEC SQL
 SELECT projcode, projdesc, start_date
 INTO :hvaprojcode, :hvaprojdesc, :hvastartdate
 FROM project
 WHERE start_date <= DATE '1998-12-01' END-EXEC.
EXEC SQL
 GET DIAGNOSTICS :numrows = ROW_COUNT end-exec.
 PERFORM VARYING i FROM 1 BY 1 UNTIL i > numrows
 display "Project: " hvaprojcode(i) hvaprojdesc(i)
 "Started: " hvastartdate(i)
 END-PERFORM
...
Rowset Arrays as Input for SELECT Statements
A SELECT statement retrieves the values in one or more columns of the matching 
rows. The matching rows are determined by the evaluation of the search condition in 
the WHERE clause of the SELECT statement.
You can use rowset arrays as input in the WHERE clause search condition to specify 
multiple values for the search condition in a single SQL statement.The use of rowset 
arrays for input is similar to a looping mechanism whereby the same statement is 
executed multiple times with a different set of values for input each time. You can use 
rowset arrays as input in the HAVING clause search condition of a SELECT statement.
COBOL










