The SUBSTR function is used to extract characters from a word or sentence.
For Example, I have run into many situations were I need to apply different programming logic based on characters in a string.
Suppose I have an employee table with an employee_id and employee_name (First, Last, middle) and I want to store the middle name in my database as middle initial only. So I only need the first character of the middle name.
I can simply do this by using a SUBSTR on the middle name field.
The first argument in the example above for the SUBSTR function is the column name. The second argument is a number which is the starting position of where you want to grab the character from; In this example I want the first character so I use 0 or you can use 1). The last argument is how many characters you want to grab from the string, in this case I want only 1 character so I said 1.
| Title | Under | Posted on |
|---|---|---|
| Embed External page into peoplesoft | PeopleSoft Technical | 06/30/2009 - 3:43am |
| Information required on Peoplesoft SCM tables | PeopleSoft Functional | 06/29/2009 - 6:02am |
| How do I return multiple rows when using START WITH in an Oracle stored procedure? | SQL & PL/SQL | 06/09/2009 - 3:44pm |
| Staging table issues | PeopleSoft Functional | 06/07/2009 - 6:59pm |
Comments
Zooz, you might want to check this post. It is the REGEXP_SUBSTR available in Oracle 10g and up. It is much more powerful than the normal SUBSTR.
Cheers!
Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog
Post new comment