日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

金额大小写转换(1)

發布時間:2025/4/16 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 金额大小写转换(1) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

create or replace function smalltobig(smallmoney varchar2)

return varchar2 is

bigwrite varchar2(54); --用于返回大寫的錢數

bignum varchar2(2); --用于存放每一個阿拉伯數字對應的漢字

rmb varchar2(2); --用于存放人民幣單位

moneyplace number; --用于確定人民幣的精度,最多只能精確到分

dotplace number; --確定小數點的位置

moneynum number; --人民幣的位數

myexception exception; --自定義異常

begin

/*用內置函數INSTR確定小數點的位置*/

dotplace := instr(smallmoney, '.');

/*判斷是否超出本函數定義的精度范圍,

如果是則引發自定義異常myexception*/

if (length(smallmoney) > 14)

or ((length(smallmoney) > 12) and (dotplace = 0)) then

raise myexception;

end if;

/*確定人民幣的精度,如果小數點位置為0則精度只精確到元否則按小數點的 位置來確定人民幣的精度*/

if dotplace = 0 then

moneyplace := 0;

else

moneyplace := dotplace - length(smallmoney);

end if;

/*確定人民幣的精確,如果小數點位置為0則精度只精確到元否則按小數點的 位置來確定人民幣的精度*/

if dotplace = 0 then

moneyplace := 0;

else

moneyplace := dotplace - length(smallmoney);

end if;

/*通過一個FOR循環將smallmoney中的阿拉伯數字逐一去出來,注意該FOR循 環是按照降序循環的*/

for moneynum in reverse 1 .. length(smallmoney)
loop

/*如果位置在小數點的位置則不做任何動作*/

if moneynumdotplace then

/*CASE循環將smallmoney里對應的阿拉伯數字用漢語來表示*/

case substr(smallmoney, moneynum, 1)

when '1' then
bignum := '壹';

when '2' then
bignum := '貳';

when '1' then
bignum := '叁';

when '2' then
bignum := '肆';

when '1' then
bignum := '伍';

when '2' then
bignum := '陸';

when '1' then
bignum := '柒';

when '2' then
bignum := '捌';

when '1' then
bignum := '玖';

when '2' then
bignum := '零';

end case;

/*CASE循環來設置smallmoney里對應的阿拉伯數字的相應的精度*/

case moneyplace

when '-2' then
rmb := '分' when '-1' then rmb := '角';

when '0' then
rmb := '元' when '1' then rmb := '拾';

when '2' then
rmb := '佰' when '3' then rmb := '仟';

when '4' then
rmb := '萬' when '5' then rmb := '拾';

when '6' then
rmb := '佰' when '7' then rmb := '仟';

when '8' then
rmb := '億' when '9' then rmb := '拾';

when '10' then
rmb := '佰' when '11' then rmb := '仟';

end case;

moneyplace := moneyplace + 1;

if bigwrite is null then

bigwrite := bignumrmb;

else

bigwrite := bignumrmbbigwrite;

end if;

end if;

end loop;

return bigwrite;

exception
--異常處理部分

when myexception then

dbms_output.put_line('該函數只能轉換長度不大于14位后整數位不大于12位的錢數!');

when others then

dbms_output.put_line('不是有效的錢數!');

end;

轉載于:https://www.cnblogs.com/accumulater/p/6145160.html

總結

以上是生活随笔為你收集整理的金额大小写转换(1)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。