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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: package to check if the input chars are number

Re: package to check if the input chars are number

From: grace lim <mglim_at_softhome.net>
Date: Mon, 10 Jul 2000 08:52:42 +0800
Message-Id: <10553.111515@fatcity.com>


to all gurus,

 thanks for the help.

 08:19 AM 7/7/00 -0700, you wrote:
>On Thu, 6 Jul 2000, grace lim wrote:
>
>> gurus,
>>
>> is there a package that can check if the input is a numeric or varchar
when
>> the variable has a varchar2 type?
>>
>> e.g. user input '123' === output is numeric
>> '2rY' === output not numeric
>
>
>There is a simple way to do this. It also happens to
>be the fastest method.
>
>Give this a try:
>
>------------------------------------------
>
>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;
>exception
>when value_error then
> return false;
>when others then
> raise;
>end;
>/
>
>show errors function is_number
>
>
>declare
> v_test varchar2(10) := '12';
>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;
>end;
>/
>------------------------------------------
>
>Jared Still
>Certified Oracle DBA and Part Time Perl Evangelist ;-)
>Regence BlueCross BlueShield of Oregon
>jkstill_at_bcbso.com - Work - preferred address
>jkstill_at_teleport.com - private
Received on Sun Jul 09 2000 - 19:52:42 CDT

Original text of this message

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