Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: numeric check

Re: numeric check

From: <lisaashleyrafter_at_yahoo.com>
Date: 24 Mar 2006 14:12:27 -0800
Message-ID: <1143238347.677146.169140@i39g2000cwa.googlegroups.com>


Hello there,
There is no built in function to accomplish that. I suggest creating a utiilties package and then putting these types of functions into that package (ie. isNumber(), etc). Here's the pl/sql you'll need:
select instr(translate( <insert your variable/string here> ,

        'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
	'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X')
FROM dual;
It returns 0 if it is a number, 1 if it is not.

If you wanted to check if the string 'HELLO' was a number, it'd be used like this:
select instr(translate( 'HELLO',

        'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
	'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X')
FROM dual;

Hope that helps,
Lisa Rafter

mr. ambastha wrote:
> i just have a doubt. till date i was writing a pl sql function for
> checking whether the entered number is numeric or not. can anyone tell
> whether there is any built in function to check this? Earlier i was
> using isdigit() and isnumeric() in other languages. is this kind of
> functions available here?
> thanks in advance,
> regards,
> -ambastha
Received on Fri Mar 24 2006 - 16:12:27 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US