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-23
Limiting the Size of the Input Rowset When
Declaring a Cursor
values (:hvajobcode, :hvajobdesc)
END-EXEC.
...
Limiting the Size of the Input Rowset When Declaring a Cursor
When you are declaring a cursor to fetch rows from the database, you can limit the
size of the input rowset. Use this general syntax in the cursor declaration when you
limit rowset size.
For information on all syntax elements of DECLARE CURSOR, see the SQL/MX
Reference Manual.
Example
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6];
ROWSET[10] unsigned NUMERIC (4) hva_jobcode;
ROWSET[10] VARCHAR hva_jobdesc[19];
NUMERIC(4) input_size;
...
EXEC SQL END DECLARE SECTION;
...
EXEC SQL DECLARE C1 CURSOR FOR
ROWSET FOR INPUT SIZE :input_size
SELECT jobdesc FROM persnl.job
WHERE jobcode = :hva_jobcode;
input_size = 3
/* Populate first 3 rows of input rowset. */
hva_jobcode[0] = 100;
hva_jobcode[1] = 200;
hva_jobcode[2] = 300;
EXEC SQL OPEN C1;
EXEC SQL FETCH C1 INTO :hva_jobdesc;
/* Only rows with jobcode 100, 200 or 300 will be returned */
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 sqlstate pic x(5).
01 rs.
DECLARE { cursor-name | ext-cursor-name}
CURSOR FOR { rowset-clause | ext-statement-name}
rowset-clause is:
ROWSET FOR [ INPUT SIZE rowset-size-in]
[ KEY BY index-identifier]
[ INPUT SIZE rowset-size-in,
KEY BY index-identifier]
<sql-statement><sql-terminator>
C
COBOL