Previous Topic: Read Sequentially by RID

Next Topic: Retrieve Records Indirectly by Key Field Stored in Another Record

Retrieve Records Sequentially by Key Field

When you want to retrieve records by any key sequence, the following technique can be used:

&NDBSEQ dbname DEFINE SEQ=seqname FIELD=keyfieldname +
FROM=fromvalue TO=tovalue
&NDBGET loop as coded in previous example..... 

This use of &NDBSEQ and &NDBGET allows sequential retrieval by any key field, and, for non-unique key fields, records with the same key field value are returned in RID sequence within the value.

The FROM and TO operands on &NDBSEQ are optional. If omitted, the lowest (FROM) or highest (TO) key values are used. For non-unique key fields, VALUE=value can be coded to indicate the from and to values are the same. This is useful when you want to read all records with the same non-unique value. For character and HEX fields, GENERIC=value can be coded to indicate the range is to cover all records with that generic key value.