How can you tell if a value is not numeric in Oracle?

前端 未结 6 1215
渐次进展
渐次进展 2020-11-27 05:37

I have the following code that returns an error message if my value is invalid. I would like to give the same error message if the value given is not numeric.



        
6条回答
  •  天命终不由人
    2020-11-27 06:19

    CREATE OR REPLACE FUNCTION IS_NUMERIC(P_INPUT IN VARCHAR2) RETURN INTEGER IS
      RESULT INTEGER;
      NUM NUMBER ;
    BEGIN
      NUM:=TO_NUMBER(P_INPUT);
      RETURN 1;
    EXCEPTION WHEN OTHERS THEN
      RETURN 0;
    END IS_NUMERIC;
    /
    

提交回复
热议问题