INSTR, INSTRB, INSTR4
Determines the first position, if any, at which one string occurs within another. If the substring does not occur in the string, 0 is returned. The position returned is always relative to the beginning of SourceExpr. INSTR returns type NUMBER.
SQL syntax
{INSTR | INSTRB | INSTR4} ( SourceExpr, SearchExpr [,m[,n]])Parameters
INSTR has the parameters:
| Parameter | Description |
|---|---|
|
|
The string to be searched to find the position of |
|
|
The substring to be found in string |
|
|
The optional position at which to begin the search. If |
|
|
If |
Description
INSTR calculates strings using characters as defined by character set. INSTRB uses bytes instead of characters. INSTR4 uses UCS4 code points.
Examples
The following example uses INSTR to determine the position at which the substring 'ing' occurs in the string 'Washington':
Command> SELECT INSTR ('Washington', 'ing') FROM dual;
< 5 >
1 row found.
The following example uses INSTR to provide the number of employees with a '650' area code as input to the COUNT function:
Command> SELECT COUNT(INSTR(phone_number, '650')) FROM employees; < 107 > 1 row found.