CREATE OR REPLACE FUNCTION is_alpha (string IN VARCHAR2) RETURN BOOLEAN
/*
|| Function tests for ALPHABETIC characters, if A-Z or a-z does NOT appear in the string then
|| FALSE is returned.
*/
IS
i NUMBER;
v_boolean BOOLEAN DEFAULT TRUE;
BEGIN
FOR i in 1 .. length(string)
LOOP
IF ascii(substr(string,i,1)) between ascii(‘A’) and ascii(‘Z’) THEN
v_boolean := TRUE;
ELSIF
ascii(substr(string,i,1)) between ascii(‘a’) and ascii(‘z’) THEN
v_boolean := TRUE;
ELSE
v_boolean := FALSE;
EXIT;
END IF;
END LOOP;
RETURN(v_boolean);
END;
/

How to test for alphabetic characters in a string

Leave a Reply

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

seventy six − = 71