oracle中用正则判断是否为数字

CREATE OR REPLACE FUNCTION ISNUMBER(VALID_STR IN VARCHAR2)
RETURN NUMBER
  IS
   CURSOR VALID_NUMBER IS
          SELECT 1 FROM DUAL WHERE regexp_like(VALID_STR ,'^[+-]?\d+(\.\d)?\d*$');
   ISNUMBER_ VALID_NUMBER%ROWTYPE;
BEGIN
   OPEN VALID_NUMBER;
   FETCH VALID_NUMBER INTO ISNUMBER_;
   IF (VALID_NUMBER%FOUND) THEN
      CLOSE VALID_NUMBER;
      RETURN 1;
   ELSE
      CLOSE VALID_NUMBER;
      RETURN 0;
   END IF;
END ISNUMBER;

你可能感兴趣的:(oracle)