LOCATE function

Function

The LOCATE function returns a 64-bit signed integer containing the position of the specified string in the large object column or variable parameter. For CHAR and VARCHAR columns, LOCATE returns a 32-bit signed integer position.

Syntax

LOCATElarge-object-column, string-expression
[, numeric-expression ] )

Parameters

large-object-column The name of the LONG VARCHAR or LONG BINARY column or variable to search.

string-expression The string of up to 255 bytes, for which you are searching.

numeric-expression The character position or offset at which to begin the search in the string. The numeric-expression is a 64-bit signed integer for LONG VARCHAR and LONG BINARY columns and is a 32-bit signed integer for CHAR, VARCHAR, and BINARY columns. The first character is position 1. If the starting offset is negative, LOCATE returns the last matching string offset, rather than the first. A negative offset indicates how much of the end of the string to exclude from the search. The number of characters excluded is calculated as ( -1 * offset ) - 1.

Usage

See also

“LOCATE function [String]” in Chapter 4, “SQL Functions” in Reference: Building Blocks, Tables, and Procedures