Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle INSTR

Oracle Tips by Burleson Consulting

Oracle INSTR

The syntax for Oracle INSTR function is as follows:

instr (s1, s2, st, t)

The Oracle INSTR  function is similar to the SUBSTR, except instead of returning the sub string, Oracle INSTR returns the location of the string.

oracle instr

SELECT
  INSTR('Now is the time for all good men',' ',1,3)
FROM
  dual; 

INSTR('NOWISTHETIMEFORALLGOODMEN','',1,3)
-----------------------------------------                                       11

1 row selected.

In the example above, I am using Oracle INSTR to look for the third occurrence of the string “ ” (a space) starting at the beginning.  According to the results of the Oracle INSTR function, the third space in the string is at character number 11.

Now for a little challenge.  Suppose that my boss wants to know what the first word of every book title is.  Think about the solution before looking at the answer below.

SELECT

  SUBSTR(book_title,1,(INSTR(book_title,' ',1,1)-1)) "First Word"
FROM
  book; 

Basically, I used the Oracle INSTR function and queried a substring of the book title starting at the first character, until the first space, minus one to remove the space from the results.  This type of Oracle INSTR query is actually very common on databases that are not properly normalized.  If the author names were stored in our PUBS database in one column, we would have to use this type of Oracle INSTR query to separate the first and last names when needed.

Oracle 10g Changes to Oracle INSTR

The Oracle INSTR function has been extended with the new function regexp_instr.

regexp_instr extends the functionality of the Oracle INSTR function by letting you search a string for a POSIX regular expression pattern. The function evaluates strings using characters, as defined by the input character set. It returns an integer indicating the beginning or ending position of the matched substring, depending on the value of the return_option argument. If no match is found, the function returns 0.

The Oracle documentation gives us the following example for the INSTR syntax:

Description of instr.gif follows

With the following description of the above illustration:

{ INSTR
| INSTRB
| INSTRC
| INSTR2
| INSTR4
}
(string , substring [, position [, occurrence ] ])

 

 

  
 
  
 
 
 

 
 
 

Oracle training Excel
 
Oracle performance tuning software 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright ? 1996 -  2014

All rights reserved by Burleson

Oracle ? is the registered trademark of Oracle Corporation.