Oracle PL/SQL is_numeric Function
By Minh • Apr 29th, 2009 • Category: OracleHere is an is_numeric function for Oracle PL/SQL.
Create the Function:
SQL> create or replace function is_numeric (v_value varchar2) return boolean is
v_data number;
begin
v_data := to_number(v_value);
return true;
exception
when others then
return false;
end is_numeric;
/
Function created.
Test the New Function:
SQL> set serveroutput on
begin
if is_numeric('123') = true then
dbms_output.put_line ('True');
else
dbms_output.put_line ('False');
end if;
if is_numeric(123) = true then
dbms_output.put_line ('True');
else
dbms_output.put_line ('False');
end if;
if is_numeric('AAA') = true then
dbms_output.put_line ('True');
else
dbms_output.put_line ('False');
end if;
end;
/
True
True
False
PL/SQL procedure successfully completed.

Minh is a technology junkie.
Email this author | All posts by Minh
