Using &NDB Verbs › Work with NDBs › Retrieve Records from an NDB
Retrieve Records from an NDB
To retrieve records from an NDB, use the &NDBGET verb. There are two related verbs:
- &NDBFMT, used to predefine a list of the fields to be returned by &NDBGET
- &NDBSEQ, used to define a sequential read path for an NDB
You can retrieve records from an NDB in several ways:
- Direct by RID, allowing EQ, GE, GT, LE, LT relationships with your RID value. This is useful when you know the RID of the record you want.
- Direct by any keyed field. The key field value of the returned record can be EQ, LE, LT, GE, GT, or generically equal to the supplied key. If the key field is not unique, only the record with the lowest RID for any set of records with the same key field value can be accessed this way.
- Sequentially by RID. Records are returned in ascending or descending RID sequence. For databases without a sequence key, this is the fastest way to read the entire database. Optionally, a starting and/or ending RID can be nominated. The last record read can also be re-read without knowing its RID.
- Sequentially by any key field (including a sequence key, if defined). Records are returned in ascending or descending key field sequence. If the key is not unique, RID is used to sequence records with an equal key field value. For databases defined with a sequence key, retrieval by that field is the fastest way to read the entire database. Optionally, a starting and/or ending key value can be nominated. The last record read can also be re-read without knowing its RID.
- Sequentially, from a list of records that passes an &NDBSCAN.
- Indirectly by a keyed field where its value is stored in another record in the NDB.
- You can also retrieve statistical information about any key field (also known as a histogram).
More information:
Scan Processing