ORACLE 小写金额转大写金额
Create Or Replace Function Money2Chinese(Money In Number) Return Varchar2 Is
strYuan Varchar2();
strYuanFen Varchar2();
numLenYuan Number;
numLenYuanFen Number;
strRstYuan Varchar2();
strRstFen Varchar2();
strRst Varchar2();
Type typeTabMapping Is Table Of Varchar2() Index By Binary_Integer;
tabNumMapping typeTabMapping;
tabUnitMapping typeTabMapping;
numUnitIndex Number;
i Number;
j Number;
charCurrentNum Char();
Begin
If Money Is Null Then
Return Null;
End If;
strYuan := TO_CHAR(FLOOR(Money));
If strYuan = '' Then
numLenYuan := ;
strYuanFen := lpad(TO_CHAR(FLOOR(Money * )), , '');
Else
numLenYuan := length(strYuan);
strYuanFen := TO_CHAR(FLOOR(Money * ));
End If;
If strYuanFen = '' Then
numLenYuanFen := ;
Else
numLenYuanFen := length(strYuanFen);
End If;
If numLenYuan = Or numLenYuanFen = Then
strRst := '零圆整';
Return strRst;
End If;
tabNumMapping() := '零';
tabNumMapping() := '壹';
tabNumMapping() := '贰';
tabNumMapping() := '叁';
tabNumMapping() := '肆';
tabNumMapping() := '伍';
tabNumMapping() := '陆';
tabNumMapping() := '柒';
tabNumMapping() := '捌';
tabNumMapping() := '玖';
tabUnitMapping(-) := '分';
tabUnitMapping(-) := '角';
tabUnitMapping() := '';
tabUnitMapping() := '拾';
tabUnitMapping() := '佰';
tabUnitMapping() := '仟';
tabUnitMapping() := '万';
tabUnitMapping() := '拾';
tabUnitMapping() := '佰';
tabUnitMapping() := '仟';
tabUnitMapping() := '亿';
For i In .. numLenYuan Loop
j := numLenYuan - i + ;
numUnitIndex := Mod(i, );
If numUnitIndex = Then
numUnitIndex := ;
End If;
If numUnitIndex = And i > Then
strRstYuan := tabUnitMapping() || strRstYuan;
End If;
charCurrentNum := substr(strYuan, j, );
If charCurrentNum <> Then
strRstYuan := tabNumMapping(charCurrentNum) ||
tabUnitMapping(numUnitIndex) || strRstYuan;
Else
If (i = Or i = ) Then
If substr(strYuan, j - , ) <> '' Then
strRstYuan := tabUnitMapping(numUnitIndex) || strRstYuan;
End If;
Else
If substr(strYuan, j + , ) <> '' Then
strRstYuan := tabNumMapping(charCurrentNum) || strRstYuan;
End If;
End If;
End If;
End Loop;
For i In - .. - Loop
j := numLenYuan - i;
charCurrentNum := substr(strYuanFen, j, );
If charCurrentNum <> '' Then
strRstFen := tabNumMapping(charCurrentNum) || tabUnitMapping(i) ||
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) = And substr(strRstFen, ) = '角' 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;
结果:
玖仟叁佰贰拾肆亿零贰佰玖拾叁万肆仟零贰拾肆圆贰角壹分
测试通过
转自:http://www.cnblogs.com/Ira_Young/archive/2009/11/11/1601168.html
ORACLE 小写金额转大写金额的更多相关文章
- odoo中Python实现小写金额转换为大写金额
自动将小写的金额数值转换为大写,方便记录 class project_parm(models.Model): def IIf(self, b, s1, s2): if b: return s1 els ...
- Excel小写金额转大写金额公式
=IF(ROUND(A6,2)<0,"无效数值",IF(ROUND(A6,2)=0,"零",IF(ROUND(A6,2)<1,"" ...
- C#实现阿拉伯数字(小写金额)到大写中文(大写金额)的转换
/// <summary> /// 本类实现阿拉伯数字到大写中文的转换 /// 该类没有对非法数字进行判别,请事先自己判断数字是否合法 /// </summary& ...
- SQL函数:小写金额转换成大写
/********************************************************作者:版本:1.0创建时间:20020227修改时间:功能:小写金额转换成大写参数:n ...
- JavaScript将小写金额转换成大写
//num为小写金额,单位元 changeMoney(num) { if(isNaN(num))return ""; var strPrefix=""; if( ...
- C#:小写金额转换为大写
#region 小写金额转换为大写 public static string CurrToChnNum(double Currnum) { string sResult = ""; ...
- C# 金额转为大写金额
/// <summary> /// 金额转为大写金额 /// </summary> public class MoneyConvertChinese { /// <sum ...
- PHP数字金额转换大写金额
早些年做CRM用到的一个金额转换函数,今天从旧项目中拿出来记录一下.金额转换的函数方法有很多,都很不错.不过这个是小崔刚工作的时候写的一个转换函数,多少还是有点纪念意义.如有问题请朋友们指出,小崔及时 ...
- SQL标量值函数:小写金额转大写
我们日常开发业务系统中,作为统计报表中,特别是财务报表,显示中文金额经常遇到. 转换大小写的方法有很多,以下是从数据库函数方面解决这一问题. 效果如图: 调用:SELECT dbo.[Fn_Conve ...
随机推荐
- Failed to execute query: Duplicate entry '0' for key 'PRIMARY'
今天在做php登陆和登出会插入数据到log表中,,结果报错了:如下: Failed to execute query: Duplicate entry '0' for key 'PRIMARY' SQ ...
- 更新证书错误Code Sign error: Provisioning profile ‘XXXX'can't be found
在Xcode中当你在更新了你得证书而再重新编译你的程序,真机调试一直会出现 Code Sign error: Provisioning profile ‘XXXX’ can't be found是不是 ...
- ADO.NET 快速入门(十一):连接池
这个示例演示了如何构建一个到数据源的连接池.你可以通过连接池部署高性能的应用程序.本例中使用连接串创建连接池,并且由 SqlConnection 自动管理. string connString; ...
- contiki-main.c 中的process系列函数学习笔记 <contiki学习笔记之六>
说明:本文依然依赖于 contiki/platform/native/contiki-main.c 文件. ---------------------------------------------- ...
- 【转】一个安全测试的CheckList
转自:http://hi.baidu.com/dontcry/item/90c2bc466558c217886d1075 不登录系统,直接输入登录后的页面的URL是否可以访问: 不登录系统,直接输入下 ...
- Posting data to a HttpHandler greater then ~29MB gives a 404 error
1down votefavorite 1 I am testing a HttpHandler that accepts XML. It works fine when a small amount ...
- Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- Codeforces Gym 100002 D"Decoding Task" 数学
Problem D"Decoding Task" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com ...
- android应用程序监听SMS Intent广播
当设备接收到一条新的SMS消息时,就会广播一个包含了android.provider.Telephony.SMS_RECEIVED动作的Intent. 对于应用程序监听SMS Intent广播,首先需 ...
- Jquery Validate根据其他元素的事件来触发单个元素的异步校验
场景:在做一个车辆信息管理模块,而车牌是通过车牌颜色和车牌号码来确定唯一性的,录入车牌信息时需对车牌进行唯一性校验.