`

人民币大小写转换function

F# 
阅读更多
create or replace function F_upper_money(p_num in number default null)
return nvarchar2 is

Result nvarchar2(100);
num_round nvarchar2(100) :=to_char(abs(round(p_num,2)));
num_left nvarchar2(100);
num_right nvarchar2(2);
str1 nchar(10) :='零壹贰叁肆伍陆柒捌玖';
str2 nchar(16) :='元拾佰仟万拾佰仟亿拾佰仟万拾佰仟';
num_pre number(1):=1;
num_current number(1);
num_count number:=0;

begin
if p_num is null then return null;end if;

select to_char(
nvl(substr(to_char(num_round),1,
decode(instr(to_char(num_round),'.'),0,
length(num_round),instr(to_char(num_round),'.')-1)),
0)) into num_left from dual;
select substr(to_char(num_round),
decode(instr(to_char(num_round),'.'),0,
length(num_round)+1,instr(to_char(num_round),'.')+1),2)
into num_right from dual;

if length(num_left)>16 then return '**********'; end if;

if length(num_right)=2 then
if to_number(substr(num_right,1,1))=0 then
result:='零'||substr(str1,to_number(substr(num_right,2,1))+1,1)||'分';
else
result:=substr(str1,to_number(substr(num_right,1,1))+1,1)||'角'||
substr(str1,to_number(substr(num_right,2,1))+1,1)||'分';
end if;
elsif length(num_right)=1 then
result:=substr(str1,to_number(substr(num_right,1,1))+1,1)||'角整';
else
result :='整';
end if;

for i in reverse 1..length(num_left) loop
num_count:=num_count+1;
num_current:=to_number(substr(num_left,i,1));
if num_current>0 then
result:=substr(str1,num_current+1,1)||substr(str2,num_count,1)||result;
else
if mod(num_count-1,4)=0 then
result:=substr(str2,num_count,1)||result;
num_pre:=0;
end if;
if num_pre>0 or length(num_left)=1 then
result:=substr(str1,num_current+1,1)||result;
end if;
end if;
num_pre:=num_current;
end loop;

if p_num<0 then
result:='负'||result;
end if;

return Result;

exception
when others then
raise_application_error(-20001,'数字转换大写出现错误!'||sqlerrm);
end ;
分享到:
评论

相关推荐

    人民币金额大小写转换控件

    人民币金额大小写转换控件V1.01 控件新增属性: property smallmoney :real;; //小写金额大小 property bigmoney1:string;; //大写金额,符合常规金额规则 property bigmoney2:string;; //大写金额二 函数...

    大小写金额转换-源码

    如¥1,680.32,应写成 人民币壹仟陆佰捌拾元零叁角贰分,或者写成人民币壹仟陆佰捌拾元 叁角贰分;又如¥107,000.53,应写成人民币壹拾万柒仟元零伍角 叁分,或者写成人民币壹拾万零柒仟元伍角叁分。 (四)...

    小写金额转换成大写金额

    编写一个收费软件时要用到一个小写金额转换成大写金额的函数,我曾在网上找到一个用Powerbuilder写的函数,长达四五十行之巨,后来我自己用DELPHI写了一个函数,寥寥几行代码就搞定: function TForm1.xTOd(i:Real):...

    PHP 实现人民币小写转换成大写的方法及大小写转换函数

    下面一段代码给大家分享php实现人民币大小写转换的方法,具体代码如下所示: &lt;?php header(charset=utf-8;); function numTrmb($num){ $d = array(零, 壹, 贰, 叁, 肆, 伍, 陆, 柒, 捌, 玖); $e = array('元'...

    python人民币小写转大写辅助工具

    本文实例为大家分享了python人民币大小写转换的具体代码,供大家参考,具体内容如下 大家应该都知道,银行打印账单有时候会跟上人民币的阿拉伯数字以及人民币汉字大写写法,转换的过程中有一定的逻辑难度,较为麻烦...

    PHP人民币金额数字转中文大写的函数代码

    在网上看到一个非常有趣的PHP人民币金额数字转中文大写的函数,其实质就是数字转换成中文大写,测试了一下,非常有趣,随便输个数字,就可以将其大写打印出来,新手朋友们试一下吧,举一反三,还可以写好多有趣的PHP...

    pb-demo-helper-function-settings.rar_pb_pb demo_pb api demo_pb

    辅助程序功能设计 实例32 使用API函数实现辅助...实例35 人民币大小写金额的转换 实例36 数据的压缩和解压缩 实例37 图像扫描实现 实例38 Flash动画的应用 实例39 键盘模拟器的实现 实例40 AresButtonPro控件的使用

    我整理的VBA 自定义函数大全 共138页

    23.人民币大小写转换 24.获取区域颜色值 25.获取活动工作表名 26.获取最后一行行数 27.判断是否连接在线 28.币种转换 29.检验工作表是否有可打印内容 30.查找一字符串(withinstr)在另一字符串中(findstr1)中某一次...

    EXCEL集成工具箱V6.0

    成本核算 【取唯一值】 还在使用&lt;分类汇总&gt;或&lt;小计&gt;功能对数据进行唯一值的繁锁操作吗? 本工具可快捷方便地取任意选中区域的存储格内容为唯一值清单,快捷且高效。 【取产品型号】 功能较在字符串中取数字强大多倍...

    EXCEL集成工具箱V8.0完整增强版(精简)

    【取唯一值】 还在使用&lt;分类汇总&gt;或&lt;小计&gt;功能对数据进行唯一值的繁锁操作吗? 本工具可快捷方便地取任意选中区域的存储格内容为唯一值清单,快捷且高效。 【取产品型号】 功能较在字符串中取数字强大多倍。能批量...

Global site tag (gtag.js) - Google Analytics