FIND( ) function

Returns a logical value indicating whether the specified string was found in a particular field, or anywhere in an entire record.

Syntax

FIND(string <,field_to_search_in>)

Parameters

string

Character. The character string to search for. The string must be enclosed in quotation marks. The search is not case-sensitive.

field_to_search_in

Optional. Character. Specifies the field, or variable, to search in. If this parameter is omitted the entire record is searched.

Output

Logical. Returns T (true) if the specified string value is found, and F (false) otherwise.

Remarks

The FIND( ) function tests for the presence of the specified string in a field, two or more fields, or an entire record. The string value can be exactly matched or it can be contained within a longer string. Leading spaces in fields do not affect the search unless you include one or more leading spaces in the string value.

If the optional field_to_search_in parameter is not specified, the entire record is searched, including any undefined portion of the record. Field boundaries are ignored when the entire record is searched, and trailing spaces in fields are treated as characters.

You can concatenate two or more fields in the field_to_search_in parameter if you want to search in a subset of the fields in a table. For example, FIND("New York", Company+City)searches both the Company and the City fields for the string “New York”. The concatenated fields are treated like a single field that includes leading and trailing spaces from the individual fields, unless you use the ALLTRIM( ) function to remove spaces. You can also build an expression that searches each field individually – for example, FIND("New York", Company) OR FIND("New York", City). If the string value includes a leading space, search results from these two approaches can differ.

The FIND( ) function is not case-sensitive, and finds both ASCII and EBCDIC characters. The function is not affected by the Exact Character Comparisons configuration setting (SET EXACT ON/OFF).

To search in a related field you must specify the fully qualified name of the field (that is, table.field name) in the field_to_search_in parameter. For example: FIND("New York", Vendor.Vendor_City)

Examples

Example Return value

FIND("New York")

Returns ‘T’ for all records that contain the string “New York” in any field, across any field boundaries, and in any undefined portion of the record. Returns ‘F’ otherwise.

FIND("New York", City)

Returns ‘T’ for all records that contain the string “New York” in the City field. Returns ‘F’ otherwise.

FIND(" New York", City)

Returns ‘T’ for all records that contain the string “New York” preceded by one or more spaces in the City field. Returns ‘F’ otherwise.

FIND("New York", Company+City)

Returns ‘T’ for all records that contain the string “New York” in either the Company or the City fields. Returns ‘F’ otherwise.

FIND("New York", Company) OR FIND("New York", City)

Returns ‘T’ for all records that contain the string “New York” in either the Company or the City fields. Returns ‘F’ otherwise.

FIND(ALLTRIM(Last_Name),Last_Name_2)

Returns ‘T’ for all records that have a value in the Last_Name_2 field that matches or contains the value in the Last_Name field. Returns ‘F’ otherwise.

FIND("%v_search_term%", Description)

Returns ‘T’ for all records that contain the value in the v_search_term variable in the Description field. Returns ‘F’ otherwise.



(C) 2013 ACL Services Ltd. All Rights Reserved. | Send feedback