溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

oracle數(shù)據(jù)庫使用游標實現(xiàn)大寫數(shù)字轉(zhuǎn)換成小寫數(shù)字

發(fā)布時間:2020-06-25 03:57:28 來源:網(wǎng)絡 閱讀:572 作者:wolihaito 欄目:數(shù)據(jù)庫

項目遇到需求,需要將大寫數(shù)字轉(zhuǎn)換成小寫。代碼如下:

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;

注:實現(xiàn)關鍵點,利用(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)})該類型和數(shù)組類似,利用鍵值查找對應的值。

                                                                                                                                   2016-05-11

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI