I finally have time to process the hand outs for the What's New and Exciting in RPG from PowerUp24. What I had hoped was the second fetch would load into the next section of the array rather than overlaying the first ten records. Instead, the fetch loads the next 20 records into slots 1-20 of the array rather than 11-30. There is some "noise" in the sample code where I am displaying stuff to the screen rather than run all of it in debug.
No, I do not have a use case for this yet. I am simply curious. Like most of you, I research and work out new ideas so when the use case does present itself, I have a solution. Thanks again @Scott Clement for the session at PowerUp.
**FREE
//121 Whats New and Exciting in RPG.pdf PowerUP24
//
ctl-opt option(*nodebugio:*srcstmt:*nounref) dftactgrp(*no) ACTGRP(*CALLER) DEBUG(*CONSTANTS);
dcl-ds gLine qualified;
Sales_Person varchar(15) inz;
Sales zoned(09) inz;
END-DS;
dcl-ds gGrowRows likeds(gLine) dim(*AUTO:40);
dcl-s gGrandTotal zoned(09) inz;
//------------------------------------------------------------------
dcl-pr RPGAUTOR extpgm;
END-PR;
dcl-pi RPGAUTOR ;
END-Pi;
exec sql declare getRows cursor for
select Sales_Person, Sales
From SALES;
clear gGrowRows;
dsply %char(%ELEM(gGrowRows));
exec sql open GetRows;
exec sql fetch next from getRows for 10 rows into :gGrowRows;
dsply %char(%ELEM(gGrowRows));
for-each gLine in gGrowRows ;
if gLine.Sales <> *zero;
gGrandTotal += gLine.Sales;
endIF;
endfor ;
dsply %char(gGrandTotal);
exec sql fetch next from getRows for 20 rows into :gGrowRows;
dsply %char(%ELEM(gGrowRows));
for-each gLine in gGrowRows ;
if gLine.Sales <> *zero;
gGrandTotal += gLine.Sales;
endIF;
endfor ;
exec sql close GetRows;
dsply %char(gGrandTotal);
*INLR = *On;
return;
------------------------------
David Taylor
Sr Application Developer
Range Resources
Fort Worth
------------------------------