DECLARE CURSOR eee AS
SELECT * FROM aaa.bbb WHERE ccc => :ddd
set :ddd = :fff
OPEN CURSOR eee
FETCH CURSOR eee INTO ggg <ten times>
Not keeping up real well on DB2 SQL, anyway, there may be a new construct for cursors in DB2 that would allow first going to ddd and then filling a matrix/table with the next 9 rows as well.
Something like this
FETCH CURSOR eee INTO ggg FOR 10 ROWS