POSITION: Finding the Position of a Substring

How to:

The POSITION function returns the position within a character string of a specified substring. If the substring does not appear in the character string, the result is 0. Otherwise, the value returned is one greater than the number of characters in the string preceding the start of the first occurrence of the substring.


Top of page

x
Syntax: How to Find the Position of a Substring
POSITION(substring IN arg)

where:

substring

character string

Is the substring to search for.

arg

character string

Is the string to be searched for the substring.

This function returns an integer value.



Example: Finding the Position of a Substring

POSITION returns the position of a substring. This example,

POSITION ('A'    IN 'AEIOU')

returns 1.

This example,

POSITION ('IOU' IN 'AEIOU')

returns 3.

This example,

POSITION ('Y'     IN 'AEIOU')

returns 0.


iWay Software