



The SEARCH statement searches a table for an element that satisfies the specified condition, and adjusts the associated index to indicate that element.
___ Format 1--Serial Search ____________________________________________
| |
| >>__SEARCH__identifier-1__ ___________________________ ______________> |
| |_VARYING__ _identifier-2_ _| |
| |_index-name-1_| |
| |
| >__ _____________________________________ ___________________________> |
| |_ ____ __END__imperative-statement-1_| |
| |_AT_| |
| |
| <_______________________________________________ |
| >____WHEN__condition-1__ _imperative-statement-2_ _|_________________> |
| |_NEXT-SENTENCE__________| |
| |
| >__ ____________ ___________________________________________________>< |
| |_END-SEARCH_| |
| |
|________________________________________________________________________|
___ Format 2--Binary Search ______________________________________________________________________
| |
| >>__SEARCH ALL__identifier-1__ _____________________________________ __________________________> |
| |_ ____ __END__imperative-statement-1_| |
| |_AT_| |
| |
| >__WHEN__ _data-name-1__ ____ __ _EQUAL__ ____ _ __ _identifier-3____________ _ _______________> |
| | |_IS_| | |_TO_| | |_literal-1_______________| | |
| | |_=_____________| |_arithmetic-expression-1_| | |
| |_condition-name-1____________________________________________________| |
| |
| <__________________________________________________________________________________ |
| >____ ______________________________________________________________________________ _|________> |
| |_AND__ _data-name-2__ ____ __ _EQUAL__ ____ _ __ _identifier-4____________ _ _| |
| | |_IS_| | |_TO_| | |_literal-2_______________| | |
| | |_=_____________| |_arithmetic-expression-2_| | |
| |_condition-name-2____________________________________________________| |
| |
| >__ _imperative-statement-2_ __ ____________ _________________________________________________>< |
| |_NEXT SENTENCE__________| |_END-SEARCH_| |
| |
|__________________________________________________________________________________________________|
The Data Division description of identifier-1 must contain an OCCURS clause with the INDEXED BY phrase. For Format-2, the Data Division description must also contain the KEY IS phrase in its OCCURS clause.
SEARCH statement execution modifies only the value in the index-name associated with identifier-1 (and, if present, of index-name-1 or identifier-2). Therefore, to search an entire 2- to 7-dimensional table, it is necessary to execute a SEARCH statement for each dimension. Before each execution, SET statements must be executed to reinitialize the associated index-names.
Subtopics:
© Copyright IBM Corp. 1991, 1998
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.