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

Home -> Community -> Usenet -> c.d.o.server -> Re: Simple problem...

Re: Simple problem...

From: Andrew Allen <andrew.allen_at_handleman.com>
Date: Thu, 27 Feb 2003 17:14:52 GMT
Message-ID: <3E5E3A82.8020605@handleman.com>


Telemachus wrote:
> But I can't find an easy solution.
>
> For 817 without rolling your own PL/SQL func...
> Is there a fast builtin way to do IS_A_NUMBER('STRING') or is_a_float() or
> is_an_integer()
>
>
> i.e. given a string return true if the string represents a valid number or
> false. Or do most people trap an error from TO_NUMBER ?
>

how about something like this
SQL$ declare num_var number;

   2 begin
   3 select 'abc' into num_var from dual;    4 end;
   5 /
declare num_var number;
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 3

so, if you get an ORA-6502 then the number is not numeric. Handle this in the exception part of your function and you are all set. I leave the details up to you, but it is simple enough.

--
Andrew
Received on Thu Feb 27 2003 - 11:14:52 CST

Original text of this message

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