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. PHP数字金额转换大写金额

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

  8. jsp页面输入小写金额转大写

    <script> function chineseNumber(num){ if (isNaN(num) || num > Math.pow(10, 12)) return &quo ...

  9. excel小写金额转换成中文大写

    假设 假设数据在A1单元格 任何一个个单元格输入公式=TEXT(INT(A1),"[dbnum2]")&"元"&IF(INT(A1*10)-IN ...

随机推荐

  1. policy

    template <class Apolicy> class Host {   Apolicy direct_policy_use;   Apolicy <SomeInternalT ...

  2. [android] 手机卫士界面切换动画

    在/res/anim/ 建立文件tran_out.xml 添加<translate>节点 设置x轴来源坐标android:fromXDelta=”0” 设置x轴目的坐标android:to ...

  3. Asp.net 与 jsp 交互 (打开或跳转页面)

    //// 打开固定大小窗体 Response.Write("<script>window.open('Tree1_edit.aspx','child','width=300,he ...

  4. GIS中栅格数据的拼接

    Datamanager Tools——Raster——Raster Dataset——Mosaic to New Raster 如果最大值是实际的真值,选择masaic operator要保留Max ...

  5. 多智能体仿真环境 NetLogo

    http://ccl.northwestern.edu/netlogo/ 创建agentcreate-turtles 10 动一动ask turtle 0 [forward 10 right 90 l ...

  6. Ubuntu 用户及组管理

    $是普通管员,#是系统管理员,在Ubuntu下,root用户默认是没有密码的,因此也就无法使用(据说是为了安全).想用root的话,得给root用户设置一个密码:sudo passwd root然后登 ...

  7. ios面试汇总

    http://www.360doc.com/content/15/0707/01/26281448_483232245.shtml

  8. ubuntu16.04安装不上有道词典的解决办法

    转自:http://www.linuxdiyf.com/linux/21143.html ubuntu16.04安装不上有道词典,提示: le@hu-pc:~/下载$ sudo dpkg -i you ...

  9. 2-4、配置Filebeat使用logstash

    配置filebeat使用logstash 重要:要将事件发送到Logstash,还需要创建一个Logstash配置管道,该管道监听传入的Beats连接并将收到的事件编入索引到Elasticsearch ...

  10. setParameter不支持传统的按位置查询方式

    setParameter不支持传统的按位置查询方式 String hql = "from Customer as c where c.cust_id = ?"; List<C ...