Doing a binary search (SEARCH ALL)
If you use
SEARCH ALL to do a binary
search, you do not need to set the index before you begin. The index
is always the one that is associated with the first index-name in
OCCURS clause. The index varies during execution
to maximize the search efficiency.
To use the
SEARCH ALL statement to search a table, the table must specify the
KEY phrases of the
OCCURS clause, or both,
and must already be ordered on the key or keys that are specified
KEY phrases. You can use a format 2
to order the table according to its defined keys, thereby making the
table searchable by the
SEARCH ALL statement. Note
SEARCH ALL will return unpredictable results
if the table has not been ordered according to the keys.
SEARCH ALL statement, you can test any key
that is named in the
KEY phrases for the table, but you must test all preceding
keys, if any. The test must be an equal-to condition, and the
WHEN phrase must specify either a key
(subscripted by the first index-name associated with the table) or
a condition-name that is associated with the key. The
can be a compound condition that is formed from simple conditions
AND as the only logical connective.
Each key and its object of comparison must be compatible according to the rules for comparison of data items. Note though that if a key is compared to a national literal or identifier, the key must be a national data item.
Defining a table (OCCURS)