将整数值从db列转换为oracle中的文本 [英] Converting integer value from a db column to text in oracle
问题描述
我在数据库中有一个要求.
I have a requirement in db.
1).表ABC,列:check_amount number number(18,4)
.这基本上包含例如的支票金额.支付给员工3000.50.
1).Table ABC, column: check_amount number number(18,4)
. This basically contains check amount for eg. 3000.50 to be paid to an employee.
现在签发一张支票,并且该支票包含数字和文本形式的该check_amount.例如,check将具有:
Now a cheque is issued and that check contains this check_amount in number as well as in text form.for eg.check will have:
pay to <emplyee_name> ****$3000.50**** ****THREE THOUSAND DOLLARS AND FIFTY CENTS****
我必须使用DB列值生成此文本,并在检查时显示它.
I have to generate this text using DB column value and display that on check.
有人可以帮我吗,我如何在oracle 11g中实现呢?
Can anybody help me out, how can i achieve this in oracle 11g ?
提示:我听说过朱利安格式,但这不起作用.任何建议,我们将不胜感激.
Hint:I have heard of Julien format, but that is not working. Any suggestions is greatly appreciated.
来自 纳林
推荐答案
由于儒略格式仅适用于整数,因此您可以将小数部分分开,然后将儒略格式技巧应用于分隔的数字.这是一个简单的演示.
Since Julian format works only for whole numbers, you can separate the decimal parts and then apply the Julian format trick to the separated numbers. Here's a simple demo.
DECLARE
x NUMBER (8, 2) := 1253.5;
y NUMBER;
z NUMBER;
BEGIN
y := FLOOR (x);
z := 100 * (x - y);
DBMS_OUTPUT.put_line (TO_CHAR (TO_DATE (y, 'j'), 'jsp'));
IF (z > 0)
THEN
DBMS_OUTPUT.put_line (TO_CHAR (TO_DATE (z, 'j'), 'jsp'));
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('err:' || SQLERRM);
END;
这篇关于将整数值从db列转换为oracle中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!