Oracle does not provide builtin function to check if a string is a number.
However, there is a function named to_number which can convert a string into a number. If the string is not a number, to_number would return, otherwise it would return the numerical value of the string.
Here is a function that makes use of to_number() to check if a string is a number.
CREATE OR REPLACE FUNCTION Is_Number (num_In_str IN VARCHAR2) RETURN BOOLEAN IS num NUMBER; BEGIN IF num_In_str IS NULL THEN RETURN NULL; END IF; num := To_Number(num_In_str); RETURN True; EXCEPTION WHEN OTHERS THEN RETURN False; END Is_Number;

Filed under:
PL/SQL
Post a Comment