The LOCATE function returns the starting position of the first occurrence of one string (called the search-string) within another string (called the source-string). If the search-string is not found and neither argument is null, the result is zero. If the search-string is found, the result is a number from 1 to the actual length of the source-string. If the optional start is specified, it indicates the character position in the source-string at which the search is to begin.
If start is specified, the function is similar to:
POSSTR( SUBSTR(source-string,start) , search-string ) + start - 1
If start is not specified, the function is equivalent to:
POSSTR( source-string , search-string )
For more information, see POSITION or POSSTR.
The result of the function is a large integer. If any of the arguments can be null, the result can be null; if any of the arguments is null, the result is the null value.
If the CCSID of the search-string is different than the CCSID of the source-string, it is converted to the CCSID of the source-string.
If a sort sequence other than *HEX is in effect when the statement that contains the LOCATE function is executed and the arguments are SBCS data, mixed data, or Unicode data, then the result is obtained by comparing weighted values for each value in the set. The weighted values are based on the sort sequence. An ICU sort sequence table may not be specified with the LOCATE function.
SELECT RECEIVED, SUBJECT, LOCATE('GOOD', NOTE_TEXT) FROM IN_TRAY WHERE LOCATE('GOOD', NOTE_TEXT) <> 0
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.