Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check data type of a variable

Status
Not open for further replies.

misterimran

Programmer
May 13, 2002
19
0
0
PK
Hi,

i want to check data type of a varible in Oracle/d2k.
as we check a numaric variable <is_numeric(x)> in php.

Regards,


 
You will need to create your own function to do this in Oracle.
 
If you can pass in the variable you want to test into a procedure as a varchar, the following code will give you some ideas.

create or replace procedure isanumber(thing_to_test IN varchar2)
as
my_num number;
BEGIN
my_num := thing_to_test;
dbms_output.put_line ('I am a number');
EXCEPTION
WHEN OTHERS
then
dbms_output.put_line ('I am NOT a number');
END;


SQL> execute isanumber('13');
I am a number

PL/SQL procedure successfully completed.

SQL>
execute isanumber('13.A');
I am NOT a number

PL/SQL procedure successfully completed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top