您好,登錄后才能下訂單哦!
項目遇到需求,需要將大寫數字轉換成小寫。代碼如下:
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。