Recently in an interview I was asked how to fetch multiple record using a single fetch statement in SQLRPGLE. I would like to know is it possible to get multiple record using a single fetch statement, if yes then can some one elaborate?
Asked
Active
Viewed 394 times
1 Answers
1
You should take a look at the SQL Reference and the Embedded SQL Programming manual
Basic form is
FETCH FROM <cursor_name> FOR <nbr_rows> INTO :array_name
From the Embedded SQL Programming manual, note that FROM
is optional unless you're specifing a new position for the cursor via the NEXT, PRIOR, FIRST, LAST, BEFORE, AFTER, CURRENT, and RELATIVE
keywords.
DCL-DS fststruct DIM(10) QUALIFIED;
sub1 INT(5);
sub2 INT(10);
sub3 INT(20);
sub4 INT(10);
END-DS;
EXEC SQL FETCH C1 FOR 10 ROWS INTO :fststruct;

Charles
- 21,637
- 1
- 20
- 44