create or replace function getBigMoneyStr(money In number) return varchar2 is
tmp_str varchar2(20);
money_str varchar2(20);
val_j varchar2(20);
len_j number;
k number;
i number;
j number;
m number;
result varchar2(40);
type my_type is varray(20) of varchar2(4);
num constant my_type := my_type('1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0');
num_str constant my_type := my_type('壹',
'贰',
'叁',
'肆',
'伍',
'陆',
'柒',
'捌',
'玖',
'零');
begin
tmp_str := to_char(money * 100);
len_j := length(tmp_str);
k := 11 - len_j;
result := substr(tmp_str, 1, 1);
m := 2;
for i in 1 .. len_j loop
begin
if k = 1 then
money_str := '仟';
elsif k = 2 then
money_str := '佰';
elsif k = 3 then
money_str := '拾';
elsif k = 4 then
money_str := '万';
elsif k = 5 then
money_str := '仟';
elsif k = 6 then
money_str := '佰';
elsif k = 7 then
money_str := '拾';
elsif k = 8 then
money_str := '元';
elsif k = 9 then
money_str := '角';
elsif k = 10 then
money_str := '分';
end if;
k := k + 1;
m := i + 1;
val_j := nvl(substr(tmp_str, m, 1), '');
if len_j = m + 5 and substr(result, length(result), 1) = '0' then
result := substr(result, 0, length(result) - 1) || '万0';
end if;
if len_j = m + 1 and substr(result, length(result), 1) = '0' then
result := substr(result, 0, length(result) - 1) || '元0';
end if;
if val_j = '0' and substr(result, length(result), 1) = '0' then
goto TheEnd;
end if;
if substr(result, length(result), 1) != '0' then
result := result || money_str;
end if;
result := result || val_j;
<<TheEnd>>
null;
end;
end loop;
--除去最后的0
for j in 1 .. 3 loop
begin
if substr(result, length(result), 1) = '0' then
result := substr(result, 0, length(result) - 1);
end if;
end;
end loop;
for i in 1 .. 10 loop
result := replace(result, num(i), num_str(i));
end loop;
return result;
end;
来自:http://jametong.itpub.net/category/5042/9386
分享到:
相关推荐
oracle数据库,使用自定义函数,实现了金额的大写转换。sql语句中,直接调用此函数即可得到金额大写。
将数字金额转化为汉字大写金额,用于理财程序的金额转化。
oracle小写人名币转大写人名币函数
一个用 Oracle 编写货币大写转换(函数不支持转换小数点) 最多可能转换21位数字
oracle中将小写金额转换为大写金额函数 oracle中将小写金额转换为大写金额函数
一个用 Oracle 编写货币大写转换(函数可转换小数点并支持四舍五入)
返回人民币大写方式(num2rmb) , 在数据库存储过程上实现数字转人民币大写汉字 。 灵活方便 。
一个用 Oracle 编写货币大写转换(用过程编写不支持转换小数点)
一个用 Oracle 编写货币大写转换(用过程编写支持转换小数点并且有四舍五入)
关于Oracle数据库各种存储形式的概述
ORACLE中数据字典大小写问题
数值金额转成大写金额,123456789转零壹贰叁肆伍陆柒捌玖,支持小数
oracle存储过程--数字大写变小写,使用存储过程将数字的大写转成小写,在程序中可以直接调用
在oracle中用psql写的人民币大小写转换
oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料oracle资料
Oracle详解Oracle详解Oracle详解Oracle详解
oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库oracle 数据库
oracle心得oracle心得oracle心得oracle心得oracle心得
ORACLE资料ORACLE资料ORACLE资料ORACLE资料ORACLE资料