Find the position of the string or char inside the string in Oracle

By Santhosh N

Oracle has a function to give the position of the char or string inside the string

syntax:

INSTR(string, substring [,position [,occurrence]])

where

1) string --> the string that is to be looked in.
2) substring --> the substring( or char) which we are looking for in the string
3) position --> The position from which we start the search (an integer value). If position is negative, then Oracle counts and searches backward from the end of string. If omitted, this defaults to 1.
4) occurrence --> this is an integer indicating which occurrence of string Oracle should search for. The value of occurrence must be positive. If this is omitted, this defaults to 1.

Ex:

INSTR('CORPORATE FLOOR','OR', 3, 2) = 14

Find the position of the string or char inside the string in Oracle  (2177 Views)