Previous Topic: Retrieve Records by Key Field

Next Topic: Retrieve Records Sequentially by Key Field

Read Sequentially by RID

When the entire database, or a large portion of it, must be read sequentially, and the order of returned records is unimportant, the following technique should be used.

&NDBSEQ dbname DEFINE SEQ=SEQ1 RID
&NDBGET dbname SEQ=SEQ1 FORMAT=fmtname
&DOWHILE &NDBRC = 0
   ...  process record
   &NDBGET dbname SEQ=SEQ1 FORMAT=fmtname
&DOEND

The &NDBSEQ statement sets up a sequential retrieval definition, that can be used on an &NDBGET statement to retrieve records sequentially by RID. By default, the options SKIP=+1 and DIR=FWD are assumed on the &NDBGET, so the database is read from lowest RID to highest RID.

Options on the &NDBSEQ statement allow specification of a low and high RID.

If the database has a sequence key, the next method will perform better.