欢迎投稿

今日深度:

oracle 判断字符是否为字母,oracle字符

oracle 判断字符是否为字母,oracle字符


create or replace function ischar(chr varchar2) return varchar2 is
  ischr varchar2(5);
begin
  select case
           when ascii(chr) between 65 and 122 THEN
            'true'
           else
            'false'
         end
    into ischr
    from dual;
  return ischr;
end;

oracle怎判断查询的列中是否包含字母

看看下边的语句可不可以
select case when regexp_like(字段名,'.([a-z]+|[A-Z])') then '包含字母' else '不包含字母' end
from 表名字

正则表达式函数:regexp_like
关键的参数是第二个:'.([a-z]+|[A-Z])'其中.表示匹配任何单字符,换行符除外
[a-z]是小写字母|或[A-Z]大写字母
 

oracle 怎判断数字字串中是否含有英文字母

简单的:一条语句搞定,SqlPlus里面select decode(length(replace(translate('字符串的值','0123456789.',' '),' ','')),0, 'is number','is not a number') from dual; 麻烦点的:写function在oracle数据库中,create or replace function f_str_or_num(str varchar2) return varchar2 is
2 v_num number;
3 v_return varchar2(60);
4 begin
5 v_num:=to_number(str);
6 v_return:=str||' is a number string!';
7 return v_return;
8 exception when others then
9 v_return:=str||' is not a number string!';
10 return v_return;
11 end f_str_or_num; 然后调用select f_str_or_num('字符串的值) from dual;
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/3544.html NewsArticle oracle 判断字符是否为字母,oracle字符 create or replace function ischar(chr varchar2) return varchar2 is ischr varchar2(5); begin select case when ascii(chr) between 65 and 122 THEN 'true' else 'false' end into ischr from dual;...
评论暂时关闭