SETLL, SETGT, READE, and READPE accept either a single bare key or a
parenthesized key list, the same as CHAIN:
SETLL custKey CUSTMAS; // bare single key
READE custKey CUSTMAS; // bare single key
SETGT (region : custKey) SALES; // composite key list
READPE (region : custKey) SALES; // composite key list, backward
SETLL positions the file at the first record whose key is greater than or equal
to the search argument (SETGT positions strictly after it). The next read then
follows the read form, not the positioning key:
- A sequential
READreads forward in key order from the positioned point, regardless of key value - soSETLL *LOVALfollowed byREADreturns the first record in the file. READEreads only records whose key matches theSETLL/SETGTkey, signalling EOF as soon as the key changes.READPEdoes the same reading backward. For a composite search argument, every key part must match - a record that matches only the leading key field is not returned.
For a composite key, positioning compares the whole search argument across the
key columns lexicographically - not just the leading column. SETLL (region : custKey) SALES followed by a sequential READ reads forward from the first record
whose (region, custKey) pair is >= the search argument, so a record whose
region matches but whose custKey sorts before the argument is not returned.
A partial key (fewer values than the file's key columns) positions on those
leading columns only. A backward READP applies the same comparison in reverse.
A search argument may be character or numeric. A numeric key - packed, zoned,
integer, unsigned, or float - is matched against the key column by its numeric
value, not by its character image, so 1002, a packed 1002, and a zoned 1002
all locate the same record and no leading-zero or decimal-point formatting affects
the match.