Oracle: Function ISNUMERIC Check Value is Number or Not

CREATE OR REPLACE FUNCTION ISNUMERIC (PARAM IN CHAR) RETURN NUMBER AS
    DUMMY VARCHAR2(100);
BEGIN
    DUMMY:=TO_CHAR(TO_NUMBER(PARAM));
    RETURN (1);
EXCEPTION
    WHEN OTHERS THEN
        RETURN (0);
END;

EXAMPLE:
SELECT * FROM EMP WHERE ISNUMERIC(PHONE) = 1;



Related Post:
- ORA-06502: PL/SQL: numeric or value errorstring
- Oracle: Extract Numbers from String

11 comments:

Post a Comment