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;