oracle資料庫使用遊標實現大寫數字轉換成小寫數字

來源:互聯網
上載者:User

標籤:oracle大寫數字轉換成小寫

項目遇到需求,需要將大寫數字轉換成小寫。代碼如下:

declaret_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

本文出自 “MST” 部落格,請務必保留此出處http://wolihaito.blog.51cto.com/1904662/1772865

oracle資料庫使用遊標實現大寫數字轉換成小寫數字

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.