1、編寫oracle函式
create or replace function moneytochinese(money in number) return varchar2 is注:如需測試該函式,請複製到oracle資料庫中,右擊函式名「moneytochinese」,選擇「test」 進行測試,輸入你想要的金額。2、在irport的database裡面寫查詢語句呼叫moneytochinese函式stryuan varchar2(150);
stryuanfen varchar2(152);
numlenyuan number;
numlenyuanfen number;
strrstyuan varchar2(600);
strrstfen varchar2(200);
strrst varchar2(800);
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;
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
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 moneytochinese;
小結:(select moneytochinese((select sum(sod.actual_unit_price * sod.actual_quantity) from sale_order_detail sod where sod.sale_order_no = oci.sell_order_no)) from dual) as majuscule_price
其中moneytochinese是函式名。sum(sod.actual_unit_price * sod.actual_quantity) 是總金額,加工數量*單價的和。
出處:
JAVA數字大寫金額轉換
public class moneyutil private static final string iunit private static final string dunit public static string tochinese string str else if str.index...
java 數字金額大寫轉換
數字金額大寫轉換,思想先寫個完整的然後將如零拾替換成零 要用到正規表示式 public static string digituppercase double n string digit string unit string head n 0 負 n math.abs n string s for...
金額數字大寫轉換
by linsl 2008 07 23 轉化格式 function numtoch num var num ch new array 零 壹 貳 叄 肆 伍 陸 柒 捌 玖 var z unit new array 元 拾 佰 仟 萬 拾 佰 仟 億 拾 佰 仟 var point new arra...