Purpose
INSTRB() searches a string for a specified substring in bytes and returns the starting byte position of the substring.
Syntax
INSTRB(string, substring [, position [, occurrence]])
Parameters
Parameter |
Description |
|---|---|
| string | The string to search. |
| substring | The substring to search for. |
| position | Optional. The position at which the search starts. The default value is 1. If the value is negative, the function searches backward from the end of the string. |
| occurrence | Optional. The occurrence of the substring whose position is returned. The default value is 1. |
Return type
The return type is NUMBER. If the specified substring is not found, the function returns 0.
Examples
In the UTF-8 string éOceanBase, the character é occupies 2 bytes. Therefore, Base begins at the eighth byte:
obclient> SELECT INSTRB('éOceanBase', 'Base') AS result FROM DUAL;
+--------+
| RESULT |
+--------+
| 8 |
+--------+
1 row in set