A way to check if a string is infact a number [message #272310] |
Thu, 04 October 2007 09:12  |
harveyb
Messages: 5 Registered: October 2007
|
Junior Member |
|
|
Hi All
I need to be able to check to see if a string is actually a number
is there any function in plsql that can do this?
so basically i want to do
val:='123';
if is_number(val) then print "is number"
else print "not number"
would print out "is number" but if val was '123A' then it would print out "not number"
(i knot this isnt valid plsql its my pseudo code)
Is there any way of doing this? I know I "could" catch the conversion with to_number with an exception and handle it that way, but its a little bit messy to do it that way, especially if there is a function that does it.
|
|
|
|
|
Re: A way to check if a string is infact a number [message #272603 is a reply to message #272310] |
Fri, 05 October 2007 12:53  |
 |
Kevin Meade
Messages: 2103 Registered: December 1999 Location: Connecticut USA
|
Senior Member |
|
|
all good advice.
Currenlty Oracle SQL does not offer an "is_this_a_number" function so you must write your own. As was indicated, a simple function that does a to_number and either returns the result or null, is the best way to go.
Good luck, Kevin
|
|
|