17,377
社区成员
发帖
与我相关
我的任务
分享
select *
from tab1
where translate(field1, '\\0123456789', '\\') is not null;
--10g以上还可以使用正则表达式函数
select * from tab1 where f_number(field1)=0
---1为数字 0不为数字
SQL> edi
已写入 file afiedt.buf
1 create or replace function f_number(p_num varchar2) return number
2 as
3 num number;
4 begin
5 if p_num is null then
6 return null;
7 end if;
8 num:=to_number(p_num);
9 return 1;
10 exception
11 when others then
12 return 0;
13* end;
SQL> /
函数已创建。
SQL> select f_number('122') from dual
2 /
F_NUMBER('122')
---------------
1
SQL> select f_number('12 22') from dual
2 /
F_NUMBER('1222')
----------------
0
SQL> select f_number(null) from dual
2 /
F_NUMBER(NULL)
--------------