Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Simple problem...
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.
-- AndrewReceived on Thu Feb 27 2003 - 11:14:52 CST