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 ...
随机推荐
- Elasticsearch简单介绍
如何对站内的数据进行检索? ElasticSearch是比较著名的一个分布式检索解决方案.传统的数据库例如mysql,oracle等,对一个关键词进行检索通常都是采用like的匹配,对性能或者数据量的 ...
- ASP.NET MVC4中用 BundleCollection
来源:http://www.cnblogs.com/madyina/p/3702314.html ASP.NET MVC4中对JS和CSS的引用又做了一次变化,在MVC3中我们这样引用资源文件: &l ...
- C#fixed关键字
fixed 语句禁止垃圾回收器重定位可移动的变量. fixed 语句只在 不安全的上下文中是允许的. Fixed 还可用于创建 固定大小缓冲区. fixed 语句设置指向托管变量的指针,并在执行该语句 ...
- 五,整型变量的读入——scanf函数
我们先不说变量怎么读入,我们先说说读入是什么?为什么要读入? 先来看一个例子,我现在需要计算两个整数的乘积.先看只用前面学过的内容的实现. #include<stdio.h> int ma ...
- node搜索codeforces 3A - Shortest path of the king
发一下牢骚和主题无关: 搜索,最短路都可以 每日一道理 人生是洁白的画纸,我们每个人就是手握各色笔的画师:人生也是一条看不到尽头的长路,我们每个人则是人生道路的远足者:人生还像是一块神奇的土地 ...
- C#-datagriview的表头高度的设置
- Codeforces Round #334 (Div. 2) D. Moodular Arithmetic 环的个数
D. Moodular Arithmetic Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/60 ...
- MyBatis之四:调用存储过程含分页、输入输出参数
在前面分别讲解了通过mybatis执行简单的增删改,多表联合查询,那么自然不能缺少存储过程调用,而且还带分页功能. 注意:表结构参见上篇讲解联合查询的表. 一.查询某班级以及该班级下面所有学生的记录 ...
- mysql-锁表机制分析(转)
为了给高并发情况下的mysql进行更好的优化,有必要了解一下mysql查询更新时的锁表机制.一.概述MySQL有三种锁的级别:页级.表级.行级.MyISAM和MEMORY存储引擎采用的是表级锁(tab ...
- C#_自动化测试3_controll IE
目前市面上有很多Web UI自动化测试框架,比如WatiN, Selinimu,WebDriver,还有VS2010中的Coded UI等等. 这些框架都可以操作Web中的控件,模拟用户输入,点击等 ...