create or replace function fn_getmoneytochina(p_money in number) return varchar2 is
/*功能:數字金額轉化為漢字金額
最大支援金額 9999999999999999.99 (支援千萬億的任何金額)
小數點支援2位
*/type myarray is table of varchar2(255);
n_str myarray := myarray('壹','貳','叄','肆','伍','陸','柒','捌','玖','零');
u_str myarray := myarray('分','角','圓','拾','佰','仟','萬','拾','佰','仟','億','拾','佰','仟','萬','拾','佰','仟');
signal varchar2(2) := null;
cur_digit number(1) := 0;
pre_digit number(1) := 0;
str_length number(2) := 0;
w_cash varchar2(20);
l_return varchar2(200);
begin
if p_money < 0 then
signal := '負';
end if;
if p_money = 0 then
return '零';
end if;
w_cash := to_char(abs(p_money)*100);
str_length := length(w_cash);
for i in 1..str_length loop
cur_digit := to_number(substr(w_cash,str_length - i + 1,1));
if i = 3 and l_return is null then
l_return := '整';
end if ;
if i > 2 or cur_digit <> 0 then
if cur_digit = 0 then
if i = 3 or i = 7 or i = 11 then
l_return := u_str(i)||l_return;
elsif pre_digit <> 0 then
l_return := '零'||l_return;
end if;
else
l_return := n_str(cur_digit)||u_str(i)||l_return;
end if;
end if;
pre_digit := cur_digit;
end loop;
if instr(l_return,'萬',1) - instr(l_return,'億',1) = 1 then
l_return := replace(l_return,'萬',null);
end if;
l_return := signal||l_return;
return(l_return);
exception
when others then
l_return := ' ';
return l_return;
end fn_getmoneytochina;
數字金額轉化大寫金額
數字金額轉化大寫金額 param val string number 字串可包含 和多餘的0 returns 原生方法 如下所示 function convertcurrency money if typeof money string if money maxnum if money 0 轉換為字...
數字金額轉化為中文大寫
數字金額轉換成中文大寫金額的函式 string int num 要轉換的小寫數字或小寫字串 return 大寫字母 小數字為兩位 function num to rmb num i 0 c while 1 else 每次將最後一位數字轉化為中文 p1 substr c1,3 n,3 p2 subst...
pb 數字轉化為大寫金額
功能描述 獲取乙個金額的大寫格式 引數及返回值說明 dsum decimal型別 returnvaleu string型別 boolean digit false int i,n,length string temp,temp1,temp2,upper1,upper2,upper upper1 零壹...