需求是这样的。   金额以分为单位 。  比如  :  1000   指的是 10元。 
我要将1000 转换为 十元 应考虑更为复杂的情况。。   比如     三百八十元七角四分     请指教 

解决方案 »

  1.   

    试试这个。如果有不准确的地方,请及时反馈。declare
     n number(14):=&n;
     ni number(1);
     bi number(2);
     s varchar(30 char);
     type num_typ is varray(10) of char(1 char);
     num num_typ:=num_typ(null,'一','二','三','四','五','六','七','八','九');
     type bit_typ is varray(14) of char(1 char);
     bit bit_typ:=bit_typ('分','角','元','十','百','千','万','十','百','千','亿','十','百','千');
    begin
     bi:=1;
     loop
      ni:=mod(n,10);
      s:=num(ni+1)||(case when num(ni+1) is not null then bit(bi)
                      when bit(bi)='元' then '元'
                      when bit(bi)='万' then '万'
                      when bit(bi)='亿' then '亿' end)||s;
      bi:=bi+1;
      n:=floor(n/10);
      exit when n=0;
     end loop;
    -- dbms_output.put_line(s);
     s:=regexp_replace(s,'(亿)([一|二|三|四|五|六|七|八|九][万|百|十|元])','\1零\2');
     s:=regexp_replace(s,'(万)([一|二|三|四|五|六|七|八|九][百|十|元])','\1零\2');
     s:=regexp_replace(s,'(千)([一|二|三|四|五|六|七|八|九][十|元|万|亿])','\1零\2');
     s:=regexp_replace(s,'(百)([一|二|三|四|五|六|七|八|九][元|万|亿])','\1零\2');
     s:=regexp_replace(s,'^一十','十');
     dbms_output.put_line(s);
    end;
    /
      

  2.   

    oracle中的translate函数可以解决此问题。