日期:2014-05-17 浏览次数:20791 次
select *
from t
where not regexp_like(t.a, '+[^[:digit:]$]+')
and length(t.a) = 5;
sys@ORCL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE FUNCTION isnumeric (str IN VARCHAR2)
2 RETURN NUMBER
3 IS
4 v_str FLOAT;
5 BEGIN
6 IF str IS NULL
7 THEN
8 RETURN 0;
9 ELSE
10 BEGIN
11 SELECT TO_NUMBER (str)
12 INTO v_str
13 FROM DUAL;
14 EXCEPTION
15 WHEN INVALID_NUMBER
16 THEN
17 RETURN 0;
18 END;
19 RETURN 1;
20 END IF;
21* END isnumeric;
sys@ORCL> /
sys@ORCL> insert into t values('abc');
1 row created.
sys@ORCL> insert into t values('123');
1 row created.
sys@ORCL> insert into t values('cde');
1 row created.
sys@ORCL> insert into t values('456122');
1 row created.
sys@ORCL> insert into t values('efd4554');
1 row created.
sys@ORCL> insert into t values (NULL);
1 row created.
sys@ORCL> commit;
Commit complete.
sys@ORCL> select * from t where isnum