最新文章专题视频专题问答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
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

OracleSQL金额小写转大写函数

来源:懂视网 责编:小采 时间:2020-11-09 16:09:28
文档

OracleSQL金额小写转大写函数

OracleSQL金额小写转大写函数:原文链接:http://www.cnblogs.com/Ira_Young/archive/2009/11/11/1601168.html 无 Create Or Replace Function Money2Chinese(Money In Number) Return Varchar2 Is strYuan Varchar2(150); strYu
推荐度:
导读OracleSQL金额小写转大写函数:原文链接:http://www.cnblogs.com/Ira_Young/archive/2009/11/11/1601168.html 无 Create Or Replace Function Money2Chinese(Money In Number) Return Varchar2 Is strYuan Varchar2(150); strYu

原文链接:http://www.cnblogs.com/Ira_Young/archive/2009/11/11/1601168.html 无 Create Or Replace Function Money2Chinese(Money In Number) Return Varchar2 Is strYuan Varchar2(150); strYuanFen Varchar2(152); numLenYuan Number; numLenYuanFen Num

原文链接:http://www.cnblogs.com/Ira_Young/archive/2009/11/11/1601168.html <无> $velocityCount-->
Create Or Replace Function Money2Chinese(Money In Number) Return Varchar2 Is
 strYuan Varchar2(150);
 strYuanFen Varchar2(152);
 numLenYuan Number;
 numLenYuanFen Number;
 strRstYuan Varchar2(600);
 strRstFen Varchar2(200);
 strRst Varchar2(800);
 Type typeTabMapping Is Table Of Varchar2(2) Index By Binary_Integer;
 tabNumMapping typeTabMapping;
 tabUnitMapping typeTabMapping;
 numUnitIndex Number;
 i Number;
 j Number;
 charCurrentNum Char(1);
Begin
 If Money Is Null Then
 Return Null;
 End If;
 strYuan := TO_CHAR(FLOOR(Money));
 If strYuan = '0' Then
 numLenYuan := 0;
 strYuanFen := lpad(TO_CHAR(FLOOR(Money * 100)), 2, '0');
 Else
 numLenYuan := length(strYuan);
 strYuanFen := TO_CHAR(FLOOR(Money * 100));
 End If;
 If strYuanFen = '0' Then
 numLenYuanFen := 0;
 Else
 numLenYuanFen := length(strYuanFen);
 End If;
 If numLenYuan = 0 Or numLenYuanFen = 0 Then
 strRst := '零圆整';
 Return strRst;
 End If;
 tabNumMapping(0) := '零';
 tabNumMapping(1) := '壹';
 tabNumMapping(2) := '贰';
 tabNumMapping(3) := '叁';
 tabNumMapping(4) := '肆';
 tabNumMapping(5) := '伍';
 tabNumMapping(6) := '陆';
 tabNumMapping(7) := '柒';
 tabNumMapping(8) := '捌';
 tabNumMapping(9) := '玖';
 tabUnitMapping(-2) := '分';
 tabUnitMapping(-1) := '角';
 tabUnitMapping(1) := '';
 tabUnitMapping(2) := '拾';
 tabUnitMapping(3) := '佰';
 tabUnitMapping(4) := '仟';
 tabUnitMapping(5) := '万';
 tabUnitMapping(6) := '拾';
 tabUnitMapping(7) := '佰';
 tabUnitMapping(8) := '仟';
 tabUnitMapping(9) := '亿';
 For i In 1 .. numLenYuan Loop
 j := numLenYuan - i + 1;
 numUnitIndex := Mod(i, 8);
 If numUnitIndex = 0 Then
 numUnitIndex := 8;
 End If;
 If numUnitIndex = 1 And i > 1 Then
 strRstYuan := tabUnitMapping(9) || strRstYuan;
 End If;
 charCurrentNum := substr(strYuan, j, 1);
 If charCurrentNum <> 0 Then
 strRstYuan := tabNumMapping(charCurrentNum) ||
 tabUnitMapping(numUnitIndex) || strRstYuan;
 Else
 If (i = 1 Or i = 5) Then
 If substr(strYuan, j - 3, 4) <> '0000' Then
 strRstYuan := tabUnitMapping(numUnitIndex) || strRstYuan;
 End If;
 Else
 If substr(strYuan, j + 1, 1) <> '0' Then
 strRstYuan := tabNumMapping(charCurrentNum) || strRstYuan;
 End If;
 End If;
 End If;
 End Loop;
 For i In -2 .. -1 Loop
 j := numLenYuan - i;
 charCurrentNum := substr(strYuanFen, j, 1);
 If charCurrentNum <> '0' Then
 strRstFen := tabNumMapping(charCurrentNum) || tabUnitMapping(i) ||
 strRstFen;
 End If;
 End Loop;
 If strRstYuan Is Not Null Then
 strRstYuan := strRstYuan || '圆';
 End If;
 If strRstFen Is Null Then
 strRstYuan := strRstYuan || '整';
 Elsif length(strRstFen) = 2 And substr(strRstFen, 2) = '角' Then
 strRstFen := strRstFen || '整';
 End If;
 strRst := strRstYuan || strRstFen;
 --strRst := Replace(strRst, '亿零', '亿');
 --strRst := Replace(strRst, '万零', '万');
 Return strRst;
End Money2Chinese;

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文档

OracleSQL金额小写转大写函数

OracleSQL金额小写转大写函数:原文链接:http://www.cnblogs.com/Ira_Young/archive/2009/11/11/1601168.html 无 Create Or Replace Function Money2Chinese(Money In Number) Return Varchar2 Is strYuan Varchar2(150); strYu
推荐度:
标签: 链接 金额 小写
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top