Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

6.2.32 SEARCH Statement



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_|                                                    |
   |                                                                                                  |
   |__________________________________________________________________________________________________|
identifier-1
Can be:

Identifier-1 must refer to all occurrences within the table element; that is, it must not be subscripted or reference-modified.

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:



Previous Topic Next Topic Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.