1、编写oracle函数

 CREATE OR REPLACE Function MoneyToChinese(Money In Number) Return Varchar2 Is
strYuan Varchar2(150);
strYuanFen Varchar2(152);
numLenYuan Number;
numLenYuanFen Number;
strRstYuan Varchar2(600);
strRstFen Varchar2(200);
strRst Varchar2(800);
Type typeTabMapping Is Table Of Varchar2(2) Index By Binary_Integer;
tabNumMapping typeTabMapping;
tabUnitMapping typeTabMapping;
numUnitIndex Number;
i Number;
j Number;
charCurrentNum Char(1);
Begin
If Money Is Null Then
Return Null;
End If;
strYuan := TO_CHAR(FLOOR(Money));
If strYuan = '' Then
numLenYuan := 0;
strYuanFen := lpad(TO_CHAR(FLOOR(Money * 100)), 2, '');
Else
numLenYuan := length(strYuan);
strYuanFen := TO_CHAR(FLOOR(Money * 100));
End If;
If strYuanFen = '' Then
numLenYuanFen := 0;
Else
numLenYuanFen := length(strYuanFen);
End If;
If numLenYuan = 0 Or numLenYuanFen = 0 Then
strRst := '零元整';
Return strRst;
End If;
tabNumMapping(0) := '零';
tabNumMapping(1) := '壹';
tabNumMapping(2) := '贰';
tabNumMapping(3) := '叁';
tabNumMapping(4) := '肆';
tabNumMapping(5) := '伍';
tabNumMapping(6) := '陆';
tabNumMapping(7) := '柒';
tabNumMapping(8) := '捌';
tabNumMapping(9) := '玖';
tabUnitMapping(-2) := '分';
tabUnitMapping(-1) := '角';
tabUnitMapping(1) := '';
tabUnitMapping(2) := '拾';
tabUnitMapping(3) := '佰';
tabUnitMapping(4) := '仟';
tabUnitMapping(5) := '万';
tabUnitMapping(6) := '拾';
tabUnitMapping(7) := '佰';
tabUnitMapping(8) := '仟';
tabUnitMapping(9) := '亿';
For i In 1 .. numLenYuan Loop
j := numLenYuan - i + 1;
numUnitIndex := Mod(i, 8);
If numUnitIndex = 0 Then
numUnitIndex := 8;
End If;
If numUnitIndex = 1 And i > 1 Then
strRstYuan := tabUnitMapping(9) || strRstYuan;
End If;
charCurrentNum := substr(strYuan, j, 1);
If charCurrentNum <> 0 Then
strRstYuan := tabNumMapping(charCurrentNum) ||
tabUnitMapping(numUnitIndex) || strRstYuan;
Else
If (i = 1 Or i = 5) Then
If substr(strYuan, j - 3, 4) <> '' Then
strRstYuan := tabUnitMapping(numUnitIndex) || strRstYuan;
End If;
Else
If substr(strYuan, j + 1, 1) <> '' Then
strRstYuan := tabNumMapping(charCurrentNum) || strRstYuan;
End If;
End If;
End If;
End Loop;
For i In -2 .. -1 Loop
j := numLenYuan - i;
charCurrentNum := substr(strYuanFen, j, 1);
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) = 2 And substr(strRstFen, 2) = '角' Then
strRstFen := strRstFen || '整';
End If;
strRst := strRstYuan || strRstFen;
--strRst := Replace(strRst, '亿零', '亿');
--strRst := Replace(strRst, '万零', '万');
Return strRst;
End MoneyToChinese;

注:如需测试该函数,请复制到Oracle数据库中,右击函数名“MoneyToChinese”,选择“test” 进行测试,输入你想要的金额。

2、在irport的Database里面写查询语句调用MoneyToChinese函数

小结:

(SELECT moneytochinese((select sum(sod.ACTUAL_UNIT_PRICE * sod.ACTUAL_QUANTITY) from SALE_ORDER_DETAIL sod where sod.sale_order_no = oci.sell_order_no)) FROM dual) as majuscule_price
其中moneytochinese是函数名。sum(sod.ACTUAL_UNIT_PRICE * sod.ACTUAL_QUANTITY) 是总金额,加工数量*单价的和。

原创作者:DSHORE

作者主页:http://www.cnblogs.com/dshore123/

原文出自:http://www.cnblogs.com/dshore123/p/8033624.html

版权声明:欢迎转载,转载务必说明出处。(如果本文对您有帮助,可以点击一下右下角的 推荐,或评论,谢谢!

irport报表,把数字金额转换成大写人民币金额的更多相关文章

  1. C#小写数字金额转换成大写人民币金额的算法

    C#小写数字金额转换成大写人民币金额的算法 第一种方法: using System.Text.RegularExpressions;//首先引入命名空间 private string DaXie(st ...

  2. SQL函数:小写金额转换成大写

    /********************************************************作者:版本:1.0创建时间:20020227修改时间:功能:小写金额转换成大写参数:n ...

  3. ABAP 金额转换成大写

     FUNCTION zzfi_change_amount.*"---------------------------------------------------------------- ...

  4. 用python实现把数字人民币金额转换成大写的脚本程序

    # -*- coding: utf-8 -*- def Num2MoneyFormat( change_number ): """ .转换数字为大写货币格式( forma ...

  5. jquery 金额转换成大写

    <script language="javascript" type="text/javascript">         function Ara ...

  6. JavaScript将小写金额转换成大写

    //num为小写金额,单位元 changeMoney(num) { if(isNaN(num))return ""; var strPrefix=""; if( ...

  7. 【PHP】金额数字转换成大写形式

    <?php /*将数字金额转成大写*/ function num_to_upper($num) { $d = array('零','壹','贰','叁','肆','伍','陆','柒','捌', ...

  8. JS把数字金额转换成中文大写数字的函数

    //把数字金额转换成中文大写数字的函数 function num2rmb ($num){ $c1="零壹贰叁肆伍陆柒捌玖"; $c2="分角元拾佰仟万拾佰仟亿" ...

  9. PHP算法--将数字金额转换成大写金额

    最近在看一些PHP算法题,遇到一个将数字金额转换成大写金额的小算法题,这里贴出自己的一个例子. 注:这个小算法适用于10万以内的金额. <?php //$num = 12345.67; func ...

随机推荐

  1. 单点登录(八)-----遇到问题-----Application Not Authorized to Use CAS

    配置好cas后访问cas  client 并没有跳转到登录页面,而是页面报错误提示: Application Not Authorized to Use CAS. The application yo ...

  2. git的一些常见问题

    from:http://hi.baidu.com/mvp_xuan/blog/item/2ba062d8cd2c9fc939012fae.html 关于linux上建库等操作请看文章: http:// ...

  3. RF parameter

    There are primarily 3 features which can be tuned to improve the predictive power of the model : 说明: ...

  4. 【Asp.net入门11】第一个ASP.NET 应用程序-创建摘要视图

    目前已经完成了应用程序的基本结构单元,受邀者也能够做出回复.这一节将添加一个支持组件,以显示收到的回复摘要,以便用户的朋友了解谁会参加晚会,并做出适当安排.在Solution Explorer中右键单 ...

  5. mysqldump参数详细说明(转)

    Mysqldump参数大全(参数来源于mysql5.5.19源码)   参数 参数说明 --all-databases  , -A 导出全部数据库. mysqldump  -uroot -p --al ...

  6. python基础之01数据类型-变量-运算浅解

    python的数据类型 1  数字 数字分为整型(int),长整型(long),浮点型(float),复数(complex) 整型较为常用的功能: >>> a=-4 >> ...

  7. python的匿名函数 lambda的使用方法详解以及使用案例

    1.匿名函数是用lambda这个关键字定义 lambda  x:x+1   第一个x代表形参,x+1相当于函数的返回值 #lambda x:x+1 第一个x代表形参,x+1相当于函数的返回值 def ...

  8. pyqt5的代码

    sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003& ...

  9. Java基础-MySQL数据库扫盲篇

    Java基础-MySQL数据库扫盲篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.数据库概述 1>.什么是数据库 数据库就是存储数据的仓库,其本质是一个文件系统,数据按 ...

  10. Spring整合Quartz定时任务 在集群、分布式系统中的应用

    概述 虽然单个Quartz实例能给予你很好的Job调度能力,但它不能满足典型的企业需求,如可伸缩性.高可靠性满足.假如你需要故障转移的能力并能运行日益增多的 Job,Quartz集群势必成为你应用的一 ...