Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Boolean Function in SQL
I don't know about any existing function but you can easily create one:
create or replace function is_number(p_argument varchar2) return boolean is
l_number NUMBER(10);
begin
l_number:=to_number(p_argument);
return TRUE;
exception
when others
then
return FALSE;
end;
/
Now you can test it with the following statement:
1 begin
2 if is_number('123')
3 then
4 dbms_output.put_line('TRUE');
5 else
6 dbms_output.put_line('FALSE');
7 end if;
8 if is_number('character')
9 then
10 dbms_output.put_line('TRUE');
11 else
12 dbms_output.put_line('FALSE');
13 end if;
14* end;
SQL> /
TRUE
FALSE
PL/SQL procedure successfully completed.
Good luck,
Reinier
<pmohanan_at_my-deja.com> wrote in message news:8rdfue$db2$1_at_nnrp1.deja.com...
> Hi..All,
>
>
> Is there any function in Oracle which returns 1/TRUE or 0/FALSE
> depending on the condition. I am trying to check whether the value of a
> particluar column is numeric.
>
> When i use to_number(col_name,'99999999') it bombs when it received a
> char_value.
>
> Is there any function like isnumber()? or ischar() in oracle.
>
> The alternative i found was
> substr(col_name,1,1) in ('0','1',.....'9')
>
> Any other alternatives?
>
> Regards,
>
> Praveen
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Wed Oct 04 2000 - 02:54:26 CDT
![]() |
![]() |