银行金额小写转大写function ORACLE
发布时间:2021-01-13 01:30:51 所属栏目:编程 来源:网络整理
导读:本日PHP站长网 52php.cn把网络自互联网的代码分享给各人,仅供参考。 create or replaceFunction Money2Chinese(moneyValues In Number) Return Varchar2 Is --moneyValue := Round(to_number(moneyValue))*100 Str1 NCHA
以下代码由PHP站长网 52php.cn网络自互联网 此刻PHP站长网小编把它分享给各人,仅供参考 create or replace Function 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,1 ); nZero := 0; --第二个判定 Else cha1 := substr(Str1,(Str3+1),1); end if; End If; --是万亿,亿,万,元位等要害位 Else IF Str3 <> 0 and nZero <> 0 Then cha1 := '零'||substr(Str1,1); nZero := 0 ; Else If Str3 <> 0 and nZero = 0 Then cha1 := substr(Str1,1); cha2 := substr(Str2,1); nZero := 0 ; Else If Str3 = 0 and nZero >= 3 Then cha1 := ''; cha2 := ''; nZero := nZero + 1; Else cha1 := ''; cha2 := substr(Str2,1); nZero := nZero + 1; End If; End If; If i=(lens-10) or i = (lens - 2) Then cha2 := substr(Str2,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; 以上内容由PHP站长网【52php.cn】网络清算供各人参考研究 假如以上内容对您有辅佐,接待保藏、点赞、保举、分享。 (编辑:湖南网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |