select * from table where rrn(table) between 2500 and 5000
I’m not positive how efficient that is, or if it is/can be indexed, so, finding some key to use may be more efficient, but, I have used rrn() quite a bit in the past. when I needed to limit results.
If you’re using different RRN() positions, but want to use the same program, pass them in as parameters, and then you can choose the range when you submit the job.
unluckily I have pretty limited exposure to RPG/SQLRPG, so, I’m probably just saying things you already know/thought of… but, I figured if nothing else, I might get some gears turning.
hope that helps.
As you already know, RRN() isn’t appropriate. You can ignore any suggestion to use it on your master file.
Since you have selection criteria as well as a key, you might simply create a new table of keys as SELECT keycol FROM mytable WHERE selectcriteria = ‘x’ (populate a secondary table with the keys from all rows that meet your selection criteria.)
The populating of the new table should be relatively fast. Now consider that keycol could be an ORDER BY criteria too.
Partitioning that new file into five parts (or four, six or whatever) gives you direct sets of unique keys that can be processed by five instances of your program. You can do the partitioning in any way that you choose — by RRN(), by copying sections into work files, by anything you want.