Oracle String/Char Function - Oracle/PLSQL INSTRC Function






This Oracle tutorial explains how to use the Oracle/PLSQL INSTRC function.

The Oracle/PLSQL INSTRC function returns the location of a substring in a Unicode string.

Syntax

The syntax for the Oracle/PLSQL INSTRC function is:

INSTRC( string, substring [, start_position [,  nth_appearance ] ] )

string is the string to search.

string can be CHAR, VARCHAR2, NCHAR, or NVARCHAR2. string can not be CLOB or NCLOB.

substring is the substring to search for in string. substring can be CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB.

start_position is optional. It defaults to 1. The first position in the string is 1. If the start_position is negative, the INSTRC function counts back start_position from the end of string and searches towards the start of string.

nth_appearance is the nth appearance of substring. This is optional, defaults to 1.

If substring is not found in string, INSTRC returns 0.





Example

INSTRC('java2s.com', 'j')
-------------------------
                        1