Q
Problem solve Get help with specific problems with your technologies, process and projects.

Searching for the last character in a string

First I want to thank you for your tip and tricks. In your answer on the above topic you search the starting position of the number like this:

string_location:=MIN(DECODE(INSTR(my_string,'0'),0,999,INSTR
(my_string,'0')),DECODE(INSTR(my_string,'1'),0,999,INSTR(my_string
('1')),....,DECODE(INSTR(my_string,'9'),0,999,INSTR(my_string,'9')));
Another possibility would be:
string_location:=INSTR(TRANSLATE(UPPER(my_string),   
'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',    
'NNNNNNNNNAAAAAAAAAAAAAAAAAAAAAAAAA'),
'A',-1);
Like this you get the last character in the string. What do you think about it?

I think it is great!!! But shouldn't the INSTR function be looking for 'N' instead? Just a minor detail.

There seems to always be more than one way to get the job done these days. And one persons resolution may not always be the best. I never would have thought about using the TRANSLATE function for solving this problem. But now I probably won't overlook it in the future!

For More Information


Dig Deeper on Oracle database design and architecture

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close