SEARCHDOWN
Use the SEARCHDOWN function to look up data within a series of data that is sorted in descending code-page byte-order. SEARCHDOWN performs a binary search on the sorted series and returns a related object that corresponds to the item found.
The byte-order of characters varies by code page. For example, because the ASCII A character (0x41) has a higher numeric value than the ASCII 0 character (0x30), the SEARCHDOWN function requires the 0 character to be sorted after the ASCII A character in the series. The EBCDIC A character (0xC1) has a lower numeric value than the EBCDIC 0 character, so the SEARCHDOWN function requires the EBCDIC A character to be sorted be after the EBCDIC 0 character in the series.
The HCL® OneTest™ Data Data Language property values change the collation order of some characters. For example, the German National Language property value is arranged in byte order, with the exception of certain characters: æ is ordered after a, e is ordered before ä, and so forth. There are particular collation rules for other National Language property values. However, there is no collation order for "Western" and "Japanese" property values, and the deprecated Data Language property values are always in byte order.
- Syntax:
- SEARCHDOWN (series-object-expression , series-item-object-expression , single-item-expression)
- Meaning:
- SEARCHDOWN (corresponding_object_to_return , descending_items_to_search , item_to_match)
- Returns:
- A single object
SEARCHDOWN performs a binary search on the item series of descending_items_to_search. The descending_items_to_search must be sorted in descending code page byte-order. The value to search for is specified as the item_to_match. The object returned (corresponding_object_to_return) must be related to descending_items_to_search by a common object name.
If no match is found, SEARCHDOWN returns "none".
Examples
- SEARCHDOWN ( Age Column:Row:DBSelect , SSN Column:Row:DBSelect
, SSN_Value:Message )
If there are ten rows in DBSelect, the search starts by comparing the first SSN Column of the fifth row with the SSN_Value in Message. If the result matches, SEARCHDOWN returns the first Age Column of that Row. If the value of SSN Column is less than the SSN_Value in Message, the search continues with the third Row. If the value of SSN Column is greater than the SSN_Value in Message, the search continues with the seventh Row in DBSelect. The search continues in this fashion until either a match is found or until one Row is selected. If there is more than one SSN Column for the selected Row, a similar search is initiated for all SSN Column's for the selected Row in DBSelect.
SEARCHDOWN returns the first Age Column for the selected Row of DBSelect.
Related functions
- EXTRACT
- LOOKUP
- SEARCHUP