POSITION: Returning the First Position of a Substring in a Source String

How to:

The POSITION function returns the first position (in characters) of a substring in a source string.


Top of page

x
Syntax: How to Return the First Position of a Substring in a Source String
POSITION(pattern, string)

where:

pattern

Alphanumeric

Is the substring whose position you want to locate. The string can be as short as a single character, including a single blank.

string

Alphanumeric

Is the string in which to find the pattern.

The data type of the returned value is Integer.



Example: Returning the First Position of a Substring

POSITION determines the position of the first capital letter I in LAST_NAME.

POSITION('I', LAST_NAME)

For STEVENS, the result is 0.

For SMITH, the result is 3.


iWay Software