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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verifing the data type 1

Status
Not open for further replies.

carlavieira

Programmer
Aug 30, 2002
8
0
0
BR
Hi,

I'd like to know how can I verify if the variable contains only the data type that I'm expecting for. In SQLSERVER we have the IS_NUMERIC, IS_CHAR... functions. Is there something similar in ORACLE? How can I use it?

Thanks.
 
Write your own function like so:

FUNCTION Is_Number(p_str IN VARCHAR2)
RETURN BOOLEAN IS
l_test NUMBER;
BEGIN
l_test := To_Number(p_str);
Return TRUE;
EXCEPTION
WHEN OTHERS
THEN
Return FALSE;
END;

Then call it in other PL/SQL blocks or in a select:

SELECT x FROM y WHERE Is_Number(z);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top