oracle数据库使用游标实现大写数字转换成小写数字

发布时间:2020-06-25 03:57:28 作者:wolihaito
来源:网络 阅读:559

项目遇到需求,需要将大写数字转换成小写。代码如下:

declare
t_zl varchar2(100);
t_ts varchar2(100);
t_l number;
hh varchar2(100);
xx varchar2(100);
type TIArray is table of varchar2(100); 
type TCArray is table of varchar2(100);
A TIArray;
 B TCArray;
cursor c is select zl,tstybm from  fc_h_qsdc2;
begin
   A:=TIArray('四十七','四十六','四十五','四十四','四十三','四十二','四十一','三十九','三十八','三十七',
   '三十六','三十五','三十四','三十三','三十二','三十一','二十九','二十八','二十七','二十六','二十五','二十四','二十三',
     '二十二','二十一','四十','三十','二十','十九','十八','十七','十六','十五','十四','十三','十二','十一','十','九','八','七','六','五','四','三','二','一'); 
   B:=TCArray('47','46','45','44','43','42','41','39','38','37','36','35','34','33','32','31','29','28','27','26','25','24','23','22','21','40','30','20','19','18','17','16','15','14','13','12','11','10','9'
   ,'8','7','6','5','4','3','2','1');
  open c;
  loop
    fetch c into t_zl,t_ts;
    exit when c%notfound;
    
    for i in 1..47 loop
      select instr(t_zl,A(i)) into xx from dual; 
        if (xx>0 and length(A(i))=3) then
          hh:=substr(t_zl,1,xx-1)||B(i)||substr(t_zl,xx+3);
          elsif(xx>0 and length(A(i))=2) then
          hh:=substr(t_zl,1,xx-1)||B(i)||substr(t_zl,xx+2);
          elsif(xx>0 and length(A(i))=1) then
          hh:=substr(t_zl,1,xx-1)||B(i)||substr(t_zl,xx+1);
          else
            hh:=t_zl;
            end if;
            t_zl:=hh;
          end loop;
            update fc_h_qsdc2 set zl=t_zl where tstybm=t_ts;
            end loop;
            close c;
            end;

注:实现关键点,利用(type type_name is table of{column_type|variable_name%type|table_name.column_name%type|table_name%rowtype}[not null] index by{pls_integer|binary_tnteger|varchar2(v_size)})该类型和数组类似,利用键值查找对应的值。

                                                                                                                                   2016-05-11

推荐阅读:
  1. php 数字转换大写汉字
  2. php英文小写转换成大写

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

oracle 数字 大写

上一篇:centos7配置memcached

下一篇:shell 脚本应用《七》批量创建用户

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》