create or replace function money2chinese(money in number) return varchar2 isstryuan varchar2(
150);
stryuanfen varchar2(
152);
numlenyuan number;
numlenyuanfen number;
strrstyuan varchar2(
600);
strrstfen varchar2(
200);
strrst varchar2(
800);
2) index by binary_integer;
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;
0) := '零'
;1) := '壹'
;2) := '貳'
;3) := '叄'
;4) := '肆'
;5) := '伍'
;6) := '陸'
;7) := '柒'
;8) := '捌'
;9) := '玖'
;分';
角';1) := ''
;2) := '拾'
;3) := '佰'
;4) := '仟'
;5) := '萬'
;6) := '拾'
;7) := '佰'
;8) := '仟'
;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
end if;
charcurrentnum := substr(stryuan, j, 1
); if charcurrentnum
<> 0
then
else
if (i = 1 or i = 5
) then
if substr(stryuan, j - 3, 4) <> '
0000
'then
end if;
else
if substr(stryuan, j + 1, 1) <> '0'
then
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
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;
測試sql如下:
select money2chinese(0932402934024.213) from dual;
結果:玖仟叄佰貳拾肆億零貳佰玖拾叄萬肆仟零貳拾肆圓貳角壹分
測試通過
**:
金額小寫轉大寫
create procedure dbo trannumbertobigfordecrypt n lowermoney numeric 15,2 v transtype int,ret varchar 200 output with encryption as descript 解密exec sp ...
金額小寫轉大寫
create procedure dbo trannumbertobigfordecrypt n lowermoney numeric 15,2 v transtype int,ret varchar 200 output with encryption as descript 解密exec sp ...
C 實現小寫金額轉大寫金額
好久沒有寫部落格了。最近專案上用到小寫轉大寫金額,公司同事還準備寫一段 來實現,後來發現架構上有現成的。其實在銀行 進銷存 crm等系統中經常可能用到 獲取金額的大寫中文文字 返回 中文數字文字 mvarordollar 數字金額大小,mstrlanguage 字串語言 p 簡體中文 c 正體中文 ...