sql语句 返回人民币 大写

CREATE OR REPLACE FUNCTION L2U -- 小写金额转换成大写
(
    n_LowerMoney IN NUMBER
)
RETURN VARCHAR2
AS
v_LowerStr VARCHAR2(200); -- 小写金额
v_UpperPart VARCHAR2(200);
v_UpperStr VARCHAR2(200); -- 大写金额
BEGIN
v_LowerStr := LTRIM(RTRIM(TO_CHAR(ROUND(n_LowerMoney,2),'9999999999999.99')));
IF SUBSTR(v_LowerStr,1,1) = '#' THEN
RETURN '转换金额超过计算范围(计算范围为:计算范围为: 0 - 9,999,999,999,999.99)';
END IF;
FOR I IN 1 .. LENGTH(v_LowerStr) LOOP
SELECT DECODE(SUBSTR(v_LowerStr,LENGTH(v_LowerStr) - I + 1,1),
'.','',
'0','零', '1','一', '2','二', '3','三', '4','四',
'5','五', '6','六', '7','七', '8','八', '9','九')||
DECODE(I,1,'分',2,'角',3,NULL,4,NULL,5,'十',6,'佰',7,'仟',8,'万',
9,'十',10,'佰',11,'仟',12,'亿',13,'十',14,'佰',15,'仟',16,'万',NULL)
INTO v_UpperPart FROM DUAL;
v_UpperStr := v_UpperPart||v_UpperStr;
END LOOP;
v_UpperStr := REPLACE(v_UpperStr,'一十','十');
v_UpperStr := REPLACE(v_UpperStr,'零十','零');
v_UpperStr := REPLACE(v_UpperStr,'零佰','零');
v_UpperStr := REPLACE(v_UpperStr,'零仟','零');
v_UpperStr := REPLACE(v_UpperStr,'零零零','零');
v_UpperStr := REPLACE(v_UpperStr,'零零','零');
v_UpperStr := REPLACE(v_UpperStr,'零角零分','');
v_UpperStr := REPLACE(v_UpperStr,'零分','整');
v_UpperStr := REPLACE(v_UpperStr,'零角','零');
v_UpperStr := REPLACE(v_UpperStr,'零亿零万零元','亿元');
v_UpperStr := REPLACE(v_UpperStr,'亿零万零元','亿元');
v_UpperStr := REPLACE(v_UpperStr,'零亿零万','亿');
v_UpperStr := REPLACE(v_UpperStr,'零万零元','万元');
v_UpperStr := REPLACE(v_UpperStr,'万零元','万元');
v_UpperStr := REPLACE(v_UpperStr,'零亿','亿');
v_UpperStr := REPLACE(v_UpperStr,'零万','万');
v_UpperStr := REPLACE(v_UpperStr,'零元','元');
v_UpperStr := REPLACE(v_UpperStr,'零零','零');

RETURN v_UpperStr;
EXCEPTION WHEN OTHERS THEN
RETURN '发生错误: '||SQLCODE||'--'||SQLERRM;
END L2U;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值