最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

大写金额转换函数

来源:动视网 责编:小OO 时间:2025-09-29 03:04:12
文档

大写金额转换函数

setserveroutputon;CREATEorreplaceFunctionDisp_dxje(THe_fyhjInNumber)returnvarchar2Is/***********************************************************************名称:大写金额转换函数**功能:收费打使用此函数*******************************************************************
推荐度:
导读setserveroutputon;CREATEorreplaceFunctionDisp_dxje(THe_fyhjInNumber)returnvarchar2Is/***********************************************************************名称:大写金额转换函数**功能:收费打使用此函数*******************************************************************
set serveroutput on;

CREATE or replace Function Disp_dxje(THe_fyhj In Number) return varchar2 Is

/**********************************************************************

* 名称:大写金额转换函数 *

* 功能:收费打使用此函数 *

************************************************************************/

temp varchar2(16):=null; --the_fyhj字符串

temp1 varchar2(2):=null; --the_fyhj各小写字符

temp2 varchar2(2):=null; --the_fyhj各大写字符

temp3 varchar2(6):=null; --the_fyhj各大写单位

temp4 varchar2(60):=Null; --the_fyhj大写金额串

i number(2):=1;

j number(2);

pp number(2); --整数位长度

len number(2); --实际位长度

ll Number:=round(THe_fyhj,2);

Begin

if The_fyhj <0 Then

ll:=The_fyhj*(-1);

End if;

temp:=ltrim(rtrim(to_char(ll)),'0');--转成字符串,并去左边多余的零

pp:=Instr(temp,'.');

if pp>0 then

temp:=ltrim(Temp,'0'); --有小数时去掉右边多余的零

end if;

len:=length(temp);

if len>16 then --费用超限

return '费用超限';

End if;

if pp>0 then --整数位长度

pp:=pp-1;

Else

pp:=len;

End if;

for i in 1..len loop

temp1:=substr(temp,i,1); --取大写数值

if temp1='1' then

temp2:='壹';

elsif temp1='2' then

temp2:='贰';

elsif temp1='3' then

temp2:='叁';

elsif temp1='4' then

temp2:='肆';

elsif temp1='5' then

temp2:='伍';

elsif temp1='6' then

temp2:='陆';

elsif temp1='7' then

temp2:='柒';

elsif temp1='8' then

temp2:='捌';

elsif temp1='9' then

temp2:='玖';

elsif temp1='0' then

temp2:='零';

else

temp2:=null;

end if;

j:=pp+1-i;

If j=13 then --取大写单位

temp3:='万'; --亿级

elsif j=12 then

temp3:='仟'; --亿级

elsif j=11 then

temp3:='佰'; --亿级

elsif j=10 then

temp3:='拾'; --亿级

elsif j=9 then

temp3:='亿';

elsif j=8 then

temp3:='仟'; --万级

elsif j=7 then

temp3:='佰'; --万级

elsif j=6 then

temp3:='拾'; --万级

elsif j=5 then

temp3:='万';

elsif j=4 then

temp3:='仟';

elsif j=3 then

temp3:='佰';

elsif j=2 then

temp3:='拾';

elsif j=1 then

temp3:='元';

elsif j=-1 then

temp3:='角';

elsif j=-2 then

temp3:='分';

else

temp3:=null;

End if;

If j<-2 Then

temp2:=null;

End If;

If temp2='零' and temp3 Not In('亿','万','元') then --取消无效的单位

temp3:=null;

End if;

temp4:=temp4||temp2||temp3;

temp4:=replace(Temp4,'零零','零'); --取消无效的零

end loop;

--取消无效的零

temp4:=replace(Temp4,'零万','万');

temp4:=replace(Temp4,'零亿','亿');

temp4:=replace(Temp4,'亿万','亿');

If ll!=0 then

temp4:=replace(temp4,'零元','元');

End if;

if the_fyhj>=0 then

if (ll*10-floor(ll*10))=0 then --整数费用

temp4:='币'||temp4||'整';

else --小数费用

temp4:='币'||temp4;

end if;

Else

if (ll*10-floor(ll*10))=0 then

temp4:='币负'||temp4||'整';

else

temp4:='币负'||temp4;

end if;

End if;

return temp4;

Exception

When Others Then

return sqlerrm;

End Disp_dxje;

declare

dxje varchar2(100);

begin

dxje:=disp_dxje(-132423423503.333);

dbms_output.put_line(dxje);

end;

文档

大写金额转换函数

setserveroutputon;CREATEorreplaceFunctionDisp_dxje(THe_fyhjInNumber)returnvarchar2Is/***********************************************************************名称:大写金额转换函数**功能:收费打使用此函数*******************************************************************
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top