Previous Topic: Retrieve Records Sequentially by Key Field

Next Topic: Retrieve Keyed Field Statistics (Histogram)

Retrieve Records Indirectly by Key Field Stored in Another Record

If the NDB has multiple record types, the key identifying the desired record is not always known immediately. The identifying key might be stored in the field of another record.

For example, if the NDB contains an ordering system, it might be necessary to access a customer record, given only an order number, the order record of which contains a key identifying a separate customer record.

NDBs allow this type of access through the .LINK option of the &NDBGET/&NDBFMT verbs. The technique is:

&NDBGET dbname RID=record ID FORMAT FIELDS .LINK +
(FROM=fldname TO=keyed-fieldname ) FIELDS formatlist

Up to 16 different records can be accessed in the one &NDBGET statement using linking; that is, one primary and up to 15 secondary records.

Any access method can be used for retrieving the first record. The retrieval method for subsequent records is equivalent to an OPT=KEQ get.