CREATE OR REPLACE FUNCTION is_numeric (string IN VARCHAR2) RETURN BOOLEAN
/*
|| Function tests for NUMERIC characters, if 0-9 does NOT appear in the string then
|| FALSE is returned.
*/
IS
i NUMBER;
v_boolean BOOLEAN DEFAULT FALSE;
BEGIN
FOR i in 1 .. length(string)
LOOP
IF substr(string,i,1) not between chr(48) and chr(57) THEN
v_boolean := FALSE;
EXIT;
ELSE
v_boolean := TRUE;
END IF;
END LOOP;
RETURN(v_boolean);
END;
/

How to test for numeric characters in a string

Leave a Reply

Your email address will not be published. Required fields are marked *

eighty − = seventy