INSTR
Description of the illustration instr.gif
The
INSTR
functions searchstring
forsubstring
. The function returns an integer indicating the position of the character instring
that is the first character of this occurrence.INSTR
calculates strings using characters as defined by the input character set.INSTRB
uses bytes instead of characters.INSTRC
uses Unicode complete characters.INSTR2
uses UCS2 code points.INSTR4
uses UCS4 code points.
position
is an nonzero integer indicating the character ofstring
where Oracle Database begins the search. Ifposition
is negative, then Oracle counts backward from the end ofstring
and then searches backward from the resulting position.
occurrence
is an integer indicating which occurrence ofstring
Oracle should search for. The value ofoccurrence
must be positive.Both
string
andsubstring
can be any of the datatypesCHAR
,VARCHAR2
,NCHAR
,NVARCHAR2
,CLOB
, orNCLOB
. The value returned is ofNUMBER
datatype.Both
position
andoccurrence
must be of datatypeNUMBER
, or any datatype that can be implicitly converted toNUMBER
, and must resolve to an integer. The default values of bothposition
andoccurrence
are 1, meaning Oracle begins searching at the first character ofstring
for the first occurrence ofsubstring
. The return value is relative to the beginning ofstring
, regardless of the value ofposition
, and is expressed in characters. If the search is unsuccessful (ifsubstring
does not appearoccurrence
times after theposition
character ofstring
), then the return value is 0.See Also:
Table 2-10, "Implicit Type Conversion Matrix" for more information on implicit conversionThe following example searches the string
CORPORATE
FLOOR
, beginning with the third character, for the string "OR
". It returns the position inCORPORATE
FLOOR
at which the second occurrence of "OR
" begins:SELECT INSTR('CORPORATE FLOOR','OR', 3, 2) "Instring" FROM DUAL; Instring ---------- 14In the next example, Oracle counts backward from the last character to the third character from the end, which is the first
O
inFLOOR
. Oracle then searches backward for the second occurrence ofOR
, and finds that this second occurrence begins with the second character in the search string :SELECT INSTR('CORPORATE FLOOR','OR', -3, 2) "Reversed Instring" FROM DUAL; Reversed Instring ----------------- 2The next example assumes a double-byte database character set.
SELECT INSTRB('CORPORATE FLOOR','OR',5,2) "Instring in bytes" FROM DUAL; Instring in bytes ----------------- 27
No. | Subject | Author | Date | Views |
---|---|---|---|---|
49 | Assign a network host to Access Control List | admin | 2016.06.07 | 352 |
48 | ADD_PRIVILEGE (2nd STEP) | admin | 2016.06.07 | 401 |
47 | CREATE_ACL (1st STEP) | admin | 2016.06.07 | 355 |
46 | ACL 보기 | admin | 2016.06.07 | 351 |
45 | Oracle 11g Access Control List for External Network Services | admin | 2016.06.07 | 340 |
44 | Access Control List (ACL) | admin | 2016.06.07 | 379 |
43 | CAPTCHA PLUG-IN | admin | 2016.05.27 | 363 |
42 | SUBSTR | admin | 2016.05.26 | 323 |
41 | FOR LOOP | admin | 2016.05.20 | 328 |
40 | ROWNUM | admin | 2016.05.19 | 289 |
39 | NVL | admin | 2016.05.19 | 206 |
» | INSTR | admin | 2016.05.19 | 870 |
37 | TREE | admin | 2016.05.18 | 811 |
36 | 3D Pie Chart | admin | 2016.05.17 | 295 |
35 | CREATE VIEW | admin | 2016.05.13 | 294 |
34 | test | admin | 2016.05.11 | 178 |
33 | BOOLEAN SAMPLE | admin | 2016.05.11 | 185 |
32 | Display Value, Return Value | admin | 2016.05.10 | 185 |
31 | Fundamentals of PL/SQL | admin | 2016.05.10 | 2107 |
30 | Interactive Report | admin | 2016.05.07 | 162 |