日期:2014-05-16  浏览次数:20388 次

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;