LOCATE function (ODBC compatible) Syntax LOCATE( char-expr1 , char-expr2, [start-position] ) Description The scalar function LOCATE returns the location of the first occurrence of char-expr1 in char-expr2. If the function includes the optional integer argument start-position, LOCATE begins searching char-expr2 at that position. If the function omits the start-position argument, LOCATE begins its search at the beginning of char-expr2. LOCATE denotes the first character position of a character expression as one. If the search fails, LOCATE returns zero. If either character expression is null, LOCATE returns a null value. Example The following example uses two string literals as character expressions. LOCATE returns a value of six: SELECT LOCATE('this', 'test this test', 1) FROM TEST;
LOCATE(THIS, ------------ 6 1 record selected |
|||