ORACLE金额转换成英文大写的函数
用法如下:get_capital_money(Currency, Money)
Currency: 货币或货币描述,将放在英文大写的前面;
Money:金额。支持两位小数点。如果需要更多的小数点,请自行修改。
create or replace function GET_CAPITAL_MONEY (
P_currency varchar2,
P_money number)
return varchar2 IS
type DIME is table of varchar2(20) index by binary_integer;
numberstr DIME;
degratstr DIME;
convertm DIME;
tmpstr varchar2(200);
T_money_int varchar2(10);
i int;
Len_T_money_int int;
T_money_dec varchar2(2);
R_value varchar2(1000) := '';
NUM number; begin
numberstr(1) :='zero';
numberstr(2) :='one';
numberstr(3) :='two';
numberstr(4) :='three';
numberstr(5) :='four';
numberstr(6) :='five';
numberstr(7) :='six';
numberstr(8) :='seven';
numberstr(9) :='eight';
numberstr(10) :='nine'; numberstr(11) :='ten';
numberstr(12) :='eleven';
numberstr(13) :='twelve';
numberstr(14) :='thirteen';
numberstr(15) :='fourteen';
numberstr(16) :='fifteen';
numberstr(17) :='sixteen';
numberstr(18) :='seventeen';
numberstr(19) :='eighteen';
numberstr(20) :='nineteen'; numberstr(21) :='';
numberstr(22) :='';
numberstr(23) :='twenty';
numberstr(24) :='thirty';
numberstr(25) :='forty';
numberstr(26) :='fifty';
numberstr(27) :='sixty';
numberstr(28) :='seventy';
numberstr(29) :='eighty';
numberstr(30) :='ninety';
degratstr(1) :='thousand';
degratstr(2) :='million';
degratstr(3) :='billion';
degratstr(4) :='trillion';
num := P_money;
if num = 0 then
R_value := 'ZERO';
end if;
T_money_int := trim(to_char(num,'9999999999'));
T_money_dec := substr(TRIM(to_char(num,'9999999999.99')),length(T_money_int)+2,2);
select decode(mod(length(T_money_int),3),1,'00'||T_money_int,2,'0'||T_money_int,T_money_int) into T_money_int from dual;
Len_T_money_int := length(T_money_int);
i := 0;
while i < Len_T_money_int loop
i := i+3;
convertm(1) := SUBSTR(T_money_int,Len_T_money_int-i+1,1);
convertm(2) := SUBSTR(T_money_int,Len_T_money_int-i+2,1);
convertm(3) := SUBSTR(T_money_int,Len_T_money_int-i+3,1);
tmpstr := '';
if convertm(1) <> '0' then
tmpstr := trim(tmpstr||' '||numberstr(to_number(convertm(1))+1)||' hundred');
end if;
if convertm(2) = '1' then
tmpstr := trim(tmpstr||' '||numberstr(to_number(convertm(3))+11));
else
if convertm(2) <> '0' then
if convertm(3) = '0' then
tmpstr := trim(tmpstr||' '||numberstr(to_number(convertm(2))+21));
else
tmpstr := trim(tmpstr||' '||numberstr(to_number(convertm(2))+21)||'-'||numberstr(to_number(convertm(3))+1));
end if;
else
if convertm(3) <> '0' then
tmpstr := trim(tmpstr||' '||numberstr(to_number(convertm(3))+1));
end if;
end if;
end if;
if i = 3 then
R_value := trim(tmpstr||' '||R_value);
else
R_value := trim(tmpstr||' '||degratstr(i/3-1)||' '||R_value);
end if;
end loop;
tmpstr := '';
if to_number(T_money_dec)>0 then
if substr(T_money_dec,1,1) = '0' then
tmpstr := 'and '||substr(T_money_dec,2,1)||'/100';
else
tmpstr := 'and '||t_money_dec||'/100';
end if;
end if;
if length(tmpstr)<1 then
R_value := upper(R_value||' only.');
else
R_value := upper(R_value||' '||tmpstr||' only.');
end if;
return P_currency||' '||R_value;
end;
ORACLE金额转换成英文大写的函数的更多相关文章
- SQLSERVER金额转换成英文大写的函数
CREATE FUNCTION [dbo].[f_num_eng] (@num numeric(15,2)) RETURNS varchar(400) WITH ENCRYPTION AS BEGIN ...
- JS把数字金额转换成中文大写数字的函数
//把数字金额转换成中文大写数字的函数 function num2rmb ($num){ $c1="零壹贰叁肆伍陆柒捌玖"; $c2="分角元拾佰仟万拾佰仟亿" ...
- PHP 数字金额转换成中文大写金额的函数 数字转中文
/** *数字金额转换成中文大写金额的函数 *String Int $num 要转换的小写数字或小写字符串 *return 大写字母 *小数位为两位 **/ function num_to_rmb($ ...
- C#中将数字金额转成英文大写金额的函数
<span style="white-space:pre"> </span>/// <summary> /// 数字转金额大写 /// 调用示例 ...
- excel小写金额转换成中文大写
假设 假设数据在A1单元格 任何一个个单元格输入公式=TEXT(INT(A1),"[dbnum2]")&"元"&IF(INT(A1*10)-IN ...
- SQL函数:小写金额转换成大写
/********************************************************作者:版本:1.0创建时间:20020227修改时间:功能:小写金额转换成大写参数:n ...
- C#小写数字金额转换成大写人民币金额的算法
C#小写数字金额转换成大写人民币金额的算法 第一种方法: using System.Text.RegularExpressions;//首先引入命名空间 private string DaXie(st ...
- ABAP 金额转换成大写
FUNCTION zzfi_change_amount.*"---------------------------------------------------------------- ...
- PHP算法--将数字金额转换成大写金额
最近在看一些PHP算法题,遇到一个将数字金额转换成大写金额的小算法题,这里贴出自己的一个例子. 注:这个小算法适用于10万以内的金额. <?php //$num = 12345.67; func ...
随机推荐
- BigDecimal取余运算
取余运算在编程中运用非常广泛,对于BigDecimal对象取余运算可以通过divideAndRemainder方法实现. public BigDecimal[] divideAndRemainder( ...
- python pandas 中 loc & iloc 用法区别
转自:https://blog.csdn.net/qq_21840201/article/details/80725433 ### 随机生DataFrame 类型数据import pandas as ...
- Mybatis的Service循环调用错误
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'z ...
- monkeyrunner 简单用例编写
monkeyrunnerfrom com.android.monkeyrunner import MonkeyRunner,MonkeyDevice,MonkeyImagedevice = Monke ...
- learnpythonthehardway EX41 相关
str.count() # str.count()方法用于统计字符串里某个字符出现的次数.可选参数为在字符串搜索的开始与结束位置. # str.count(sub, start= 0,end=len( ...
- javaee 第六周作业
一.jsf(java server faces)的运行原理(工作方式) 1.jsf应用是事件驱动的,当一个事件发生时(比如用户单击一个按钮),事件通知通过HTTP发往服务器,服务器端使用叫做Faces ...
- java-基于泛型和反射机制的通用比较器实现
一.前言 Java的比较器是用来对List集合进行排序用的,分为内部比较器和外部比较器两类 内部比较器:被排序的类要 implements Comparable 类,并实现compareTo方法. 外 ...
- C语言常用关键字及运算符操作---关键字
每个知识点4问: 1. 是什么? 2. 什么时间用? 3. 怎么用? 4.为什么这么用? 1. 32个关键字 //(1)sizeof 的用法 //sizeof 是关键字,让编译器帮我们查看内存空间存储 ...
- linux ABORT的应用详解
NAME ABORT - 退出当前事务 SYNOPSIS ABORT [ WORK | TRANSACTION ] DESCRIPTION 描述 ABORT 回卷当前事务并且废弃所有当前事务中做的更新 ...
- 项目中常用的js方法(持续更新)
<script> var utils = { //时间戳转日期(timestamp:时间戳 默认当前时间) dateFormat: function(timestamp = new Dat ...