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 小写金额转大写金额的更多相关文章

  1. odoo中Python实现小写金额转换为大写金额

    自动将小写的金额数值转换为大写,方便记录 class project_parm(models.Model): def IIf(self, b, s1, s2): if b: return s1 els ...

  2. Excel小写金额转大写金额公式

    =IF(ROUND(A6,2)<0,"无效数值",IF(ROUND(A6,2)=0,"零",IF(ROUND(A6,2)<1,"" ...

  3. C#实现阿拉伯数字(小写金额)到大写中文(大写金额)的转换

    /// <summary>    /// 本类实现阿拉伯数字到大写中文的转换    /// 该类没有对非法数字进行判别,请事先自己判断数字是否合法    /// </summary& ...

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

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

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

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

  6. C#:小写金额转换为大写

    #region 小写金额转换为大写 public static string CurrToChnNum(double Currnum) { string sResult = ""; ...

  7. C# 金额转为大写金额

    /// <summary> /// 金额转为大写金额 /// </summary> public class MoneyConvertChinese { /// <sum ...

  8. PHP数字金额转换大写金额

    早些年做CRM用到的一个金额转换函数,今天从旧项目中拿出来记录一下.金额转换的函数方法有很多,都很不错.不过这个是小崔刚工作的时候写的一个转换函数,多少还是有点纪念意义.如有问题请朋友们指出,小崔及时 ...

  9. SQL标量值函数:小写金额转大写

    我们日常开发业务系统中,作为统计报表中,特别是财务报表,显示中文金额经常遇到. 转换大小写的方法有很多,以下是从数据库函数方面解决这一问题. 效果如图: 调用:SELECT dbo.[Fn_Conve ...

随机推荐

  1. 浅析网站开发中的 meta 标签的作用

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  2. Lua学习笔记(四):表和数组

    表 在Lua中,表(table)是十分重要的一种数据结构,实际上Lua对于复杂数据类型也仅提供了表给我们,我们通过表可以实现我们需要的大部分重要的数据结构,比如数组. table类型实现了关联数组,关 ...

  3. ecshop以幻灯版调用首页主广告显示

    默认的是index_ad.lbi模板有一个$flash变量了,但在搜索搜索没发现 <!--{foreach from=$flash name=no item=flash}--> <l ...

  4. MPAndroiddChart的使用

    效果图 代码: package com.jiahao.me; import java.util.ArrayList; import java.util.List; import android.app ...

  5. 华为C语言笔试题集合

    ①华为笔试题搜集 1.static有什么用途?(请至少说明两种)     1)在函数体,一个被声明为静态的变量在这一函数被调用过程中维持其值不变.     2) 在模块内(但在函数体外),一个被声明为 ...

  6. .net自动生成版本号

    在 AssemblyInfo.cs 文件中 修改 一下属性 [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFi ...

  7. SPOJ LIS2 Another Longest Increasing Subsequence Problem 三维偏序最长链 CDQ分治

    Another Longest Increasing Subsequence Problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://a ...

  8. osg通过glsl实现一个平面的水效果(法线贴图) 【转】

    转自 http://blog.sina.com.cn/s/blog_78ea87380101ehk3.html 此文实现一个简单的的水面效果,主要是法线贴图, 效果图如下:   此文分为三部分:ver ...

  9. ROR 环境的 搭建

    1)安装RUBY:从 http://www.ruby-lang.org/en/ 下载 ruby182-15.exe,安装Ruby.ruby -v 看是否安装成功.2)安装RAILS框架 :gem in ...

  10. C语言--enum,typedef enum 枚举类型详解

    原文:http://z515256164.blog.163.com/blog/static/32443029201192182854300/ 有改动 C语言详解 - 枚举类型 注:以下全部代码的执行环 ...