支票上需要把日期转换成大写,改怎么?具体要求如下:一至九月要写为:零壹、零贰、零叁、零肆、零伍、  
零陆、零柒、零捌、零玖  
十至十二月写为:壹拾月、壹拾壹月、壹拾贰月  
日子照此办理比如2005年8月3日  
应写为:贰零零伍年零捌月零叁日  
2005年11月22日  
应写为:二零零伍年壹拾壹月贰拾贰日 比如函数名为:date_change();date_change('2005-11-22')--返回结果:二零零伍-壹拾壹-贰拾贰

解决方案 »

  1.   

    SQL> create or replace function date_change(in_date in date)
      2         return varchar2 is
      3       v_date varchar2(30);
      4  begin
      5       v_date := to_char(in_date,'yyyy-mm-dd');
      6       v_date := translate(v_date,'0123456789-','零壹贰叁肆伍陆柒捌玖-');
      7       --v_date := replace(v_date,'0','零');
      8       return v_date;
      9  end;
    10  /函数已创建。SQL> select date_change(sysdate) from dual;DATE_CHANGE(SYSDATE)
    --------------------------------------------------------------------------------
    贰零零捌-零伍-壹壹SQL>
      

  2.   

    这个可以解决你的问题:
    有什么问题再说。
    --------------------------------------
    create or replace function date_change(
        v_src           in varchar2,
        v_date_format   in varchar2 default 'yyyy-mm-dd'
    )return varchar2 is
        v_result        varchar2(200);
        v_year          varchar2(4) default '';
        v_month         varchar2(4) default '';
        v_day           varchar2(4) default '';
        v_result_year   varchar2(20) default '';
        v_result_month  varchar2(20) default '';
        v_result_day    varchar2(20) default '';
    begin
        v_year  := to_char(to_date(v_src,v_date_format),'yyyy');
        v_month := to_char(to_date(v_src,v_date_format),'mm');
        v_day   := to_char(to_date(v_src,v_date_format),'dd');
        
        v_result_year := translate(v_year,'0123456789','零壹贰叁肆伍陆柒捌玖');
        if v_month < 10 then
            v_result_month := translate(v_month,'0123456789','零壹贰叁肆伍陆柒捌玖');
        else
            v_result_month := translate(substr(v_month,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖') || '拾';
            v_result_month := v_result_month || translate(substr(v_month,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖');
            if (v_month mod 10) = 0 then
                v_result_month :=  '零' || v_result_month;
            end if;
        end if;
        if v_day < 10 then
            v_result_day := translate(v_day,'0123456789','零壹贰叁肆伍陆柒捌玖');
        else
            v_result_day := translate(substr(v_day,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖') || '拾';
            v_result_day := v_result_day || translate(substr(v_day,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖');
            v_result_day := RTrim(v_result_day,'零');
            if (v_day mod 10) = 0 then
                v_result_day := '零' ||v_result_day;
            end if;
        end if;
        v_result := v_result_year || '-' || v_result_month || '-' || v_result_day;
        return(v_result);
    end date_change;
      

  3.   

    SELECT translate('2005年11月22日','0123456789','零壹贰叁肆伍陆柒捌玖') FROM dual 
      

  4.   

    select date_change('2008-10-10') from dual返回的结果为:贰零零捌-零壹拾零-零壹拾正确的结果应为:贰零零捌-零壹拾-零壹拾
      

  5.   

    Sorry,写少一个,
    这个你再试验一下。
    create or replace function date_change( 
        v_src           in varchar2, 
        v_date_format   in varchar2 default 'yyyy-mm-dd' 
    )return varchar2 is 
        v_result        varchar2(200); 
        v_year          varchar2(4) default ''; 
        v_month         varchar2(4) default ''; 
        v_day           varchar2(4) default ''; 
        v_result_year   varchar2(20) default ''; 
        v_result_month  varchar2(20) default ''; 
        v_result_day    varchar2(20) default ''; 
    begin 
        v_year  := to_char(to_date(v_src,v_date_format),'yyyy'); 
        v_month := to_char(to_date(v_src,v_date_format),'mm'); 
        v_day   := to_char(to_date(v_src,v_date_format),'dd'); 
         
        v_result_year := translate(v_year,'0123456789','零壹贰叁肆伍陆柒捌玖'); 
        if v_month  < 10 then 
            v_result_month := translate(v_month,'0123456789','零壹贰叁肆伍陆柒捌玖'); 
        else 
            v_result_month := translate(substr(v_month,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖')  ¦ ¦ '拾'; 
            v_result_month := v_result_month  ¦ ¦ translate(substr(v_month,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖'); 
            if (v_month mod 10) = 0 then 
                v_result_month :=  '零'  ¦ ¦ RTrim(v_result_month,'零');  
            end if; 
        end if; 
        if v_day  < 10 then 
            v_result_day := translate(v_day,'0123456789','零壹贰叁肆伍陆柒捌玖'); 
        else 
            v_result_day := translate(substr(v_day,1,1),'0123456789','零壹贰叁肆伍陆柒捌玖')  ¦ ¦ '拾'; 
            v_result_day := v_result_day  ¦ ¦ translate(substr(v_day,2,1),'0123456789','零壹贰叁肆伍陆柒捌玖'); 
            v_result_day := RTrim(v_result_day,'零'); 
            if (v_day mod 10) = 0 then 
                v_result_day := '零'  ¦ ¦v_result_day; 
            end if; 
        end if; 
        v_result := v_result_year  ¦ ¦ '-'  ¦ ¦ v_result_month  ¦ ¦ '-'  ¦ ¦ v_result_day; 
        return(v_result); 
    end date_change;