|
Re: Check to see if a field has a ... try this [message #371539 is a reply to message #371532] |
Fri, 03 November 2000 11:47 |
Andrew again...
Messages: 270 Registered: July 2000
|
Senior Member |
|
|
CREATE OR REPLACE FUNCTION to_num (v_value IN VARCHAR2)
RETURN NUMBER
IS
v_retval NUMBER;
BEGIN
v_retval := TO_NUMBER (v_value);-- try to convert it!
RETURN v_retval;-- return the number!
EXCEPTION
WHEN OTHERS
THEN
RETURN NULL;-- Whoops! cant convert, return null!
END to_num;
select to_num('123') from dual;
select to_num(123) from dual;
select to_num('xyz') from dual;
|
|
|