Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: ** numeric check
An oldy, but a goody.
BTW, an internet search would turn up several references to this.
Essentially you need to use the to_number() function, and test for errors.
There are other ways, but this has proven to be the fastest.
I'm sure that someone will point out that the 'raise' is unnecessary. :)
Jared
create or replace function is_number( chk_data_in varchar2 )
return boolean
is
dummy number(38,4);
begin
dummy := to_number(chk_data_in); return true;
return false;
when others then
raise;
end;
/
show errors function is_number
declare
v_test varchar2(10) := '1E';
begin
if is_number(v_test) then dbms_output.put_line(v_test || ' is a number'); else dbms_output.put_line(v_test || ' is NOT a number'); end if;
A Joshi <ajoshi977_at_yahoo.com>
Sent by: oracle-l-bounce_at_freelists.org
07/12/2004 02:29 PM
Please respond to
oracle-l_at_freelists.org
To
oracle-l_at_freelists.org
cc
Subject
** numeric check
Hi,
I have a varchar2 column which contains some text and some totally
numeric values. Is there an easy way to check if the value is totally
numeric instead of looking at ascii values etc. Thanks for your help.
![]() |
![]() |