您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

银行金额小写转大写function ORACLE

2024/6/20 7:27:16发布22次查看
平台:oracle 项目:银行支票打印功能实现小写转大写 代码出处:原创 之前网上找过相关类似的功能,但是经过测试还是会有部分漏洞,现在这些漏洞基本上解决,但难免会有遗漏希望指出。 无 create or replacefunction money2chinese(moneyvalues in number) re
平台:oracle
项目:银行支票打印功能实现小写转大写
代码出处:原创
之前网上找过相关类似的功能,但是经过测试还是会有部分漏洞,现在这些漏洞基本上解决,但难免会有遗漏  希望指出。 create or replacefunction money2chinese(moneyvalues in number) return varchar2 is --moneyvalue := round(to_number(moneyvalue))*100 str1 nchar(10) := '零壹贰叁肆伍陆柒捌玖'; str2 nchar(15) := '萬仟佰拾亿仟佰拾萬仟佰拾元角分'; str3 number(10); moneyvalue varchar2(100) := trim(to_char(moneyvalues)*100); --保留小数并去掉小数点后的值 chinesevalue varchar2(600); lens number := trim(length(moneyvalue)); nzero number := 0; cha1 nchar(10); cha2 nchar(10);begin --判断为空时 if lens is null then return null; end if; --判断位数超长时 超过15位不进行处理 if lens >15 then return '超出银行支票取值范围'; end if; if moneyvalue = 0 then return '零元整'; end if; --以上条件测试之后可以运行 --下面条件选项待测 str2 := substr(str2,(length(str2)-lens)+1, lens); for i in 1..lens loop str3 := substr(trim(moneyvalue),i,1); --循环遍历数值 if i lens-2 and i lens-6 and i lens-10 and i lens-14 --不是万亿,亿,万,元位等关键位 then if str3=0 then cha1 := ''; cha2 := ''; nzero := nzero +1; --第一个判断 else if str3 0 and nzero 0 then cha1 := '零'||substr(str1 , str3+1 , 1); cha2 := substr(str2 , i ,1 ); nzero := 0; --第二个判断 else cha1 := substr(str1 , (str3+1) ,1); cha2 := substr(str2 , i ,1); end if; end if; --是万亿,亿,万,元位等关键位 else if str3 0 and nzero 0 then cha1 := '零'||substr(str1 , str3+1 ,1); cha2 := substr(str2 , i , 1); nzero := 0 ; else if str3 0 and nzero = 0 then cha1 := substr(str1 , str3+1 ,1); cha2 := substr(str2 , i , 1); nzero := 0 ; else if str3 = 0 and nzero >= 3 then cha1 := ''; cha2 := ''; nzero := nzero + 1; else cha1 := ''; cha2 := substr(str2 , i ,1); nzero := nzero + 1; end if; end if; if i=(lens-10) or i = (lens - 2) then cha2 := substr(str2 , i ,1); end if; end if; end if; chinesevalue := chinesevalue||trim(cha1)||trim(cha2); end loop; --结束循环 if str3 = 0 then chinesevalue := chinesevalue||'整'; end if; return chinesevalue;end money2chinese;
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product