ORA-01438: 该列允许的值大于指定的精度

Posted

技术标签:

【中文标题】ORA-01438: 该列允许的值大于指定的精度【英文标题】:ORA-01438: value larger than specified precision allowed for this column 【发布时间】:2012-10-01 06:22:30 【问题描述】:

以下是我的代码,我不明白我做错了什么。任何帮助将不胜感激

CREATE OR REPLACE
PROCEDURE COMP_LATE_FEE(LATE_APT_FINE IN NUMBER, LATE_GRG_FINE IN NUMBER)
AS
DIFF NUMBER;
TYPE MBCUR IS REF CURSOR RETURN MONTHLY_BILL%ROWTYPE;
MONBILL MBCUR;
MBREC MONTHLY_BILL%ROWTYPE;
BEGIN
--DIFF := FLOOR(SYSDATE - (TRUNC(SYSDATE,'MM')));
--DBMS_OUTPUT.PUT_LINE(DIFF);

OPEN MONBILL FOR
    -- checking the status of all last month's bills
    SELECT * FROM MONTHLY_BILL
    WHERE STATUS = 'PENDING' AND SYSDATE > ED_DT;
FETCH MONBILL INTO MBREC;
    -- adding the late fee amount for any bills that are past the due date
    -- due date = last day of the month
    DIFF := FLOOR(ABS(MBREC.ED_DT - (TRUNC(SYSDATE,'MM'))));
    UPDATE MONTHLY_BILL
    SET LATE_FEE = DIFF * LATE_APT_FINE
    WHERE BILL_NUM = MBREC.BILL_NUM;
    -- if a garage is rented by the resident then the respective additional fee is included
    IF (MBREC.GARAGE_RENT != 0) THEN
        UPDATE MONTHLY_BILL
        SET LATE_FEE = LATE_FEE + DIFF * LATE_GRG_FINE
        WHERE BILL_NUM = MBREC.BILL_NUM;
    END IF;

    COMMIT;
CLOSE MONBILL;
 END;
/

程序编译没有任何错误。但是当我调用 proc 时出现以下错误

BEGIN
COMP_LATE_FEE(70,20);
END;
/

错误报告:

ORA-01438: value larger than specified precision allowed for this column
ORA-06512: at "LALLURI.COMP_LATE_FEE", line 19
ORA-06512: at line 2
01438. 00000 -  "value larger than specified precision allowed for this column"
*Cause:    When inserting or updating records, a numeric value was entered
           that exceeded the precision defined for the column.
*Action:   Enter a value that complies with the numeric column's precision,
           or use the MODIFY option with the ALTER TABLE command to expand
           the precision.

【问题讨论】:

一些中间计算的结果比 var 可以存储的要大。也许排队:LATE_FEE = LATE_FEE + DIFF * LATE_GRG_FINE。检查变量类型。 【参考方案1】:

假设第 19 行的语句是这样的

UPDATE MONTHLY_BILL
SET LATE_FEE = DIFF * LATE_APT_FINE
WHERE BILL_NUM = MBREC.BILL_NUM;

问题似乎是diff * late_apt_fine 的计算结果对于monthly_bill 表中的late_fee 列来说太大了。根据传入的参数值我们知道late_apt_fine是70。由于我们不知道出现错误时diff变量的值,也不知道@的定义monthly_bill中的987654327@列,很难知道问题是late_fee的定义需要改变还是计算值比你预期的大,需要改变算法。

【讨论】:

谢谢凯夫先生。我明白为什么现在会出现问题。感谢您花时间解释。

以上是关于ORA-01438: 该列允许的值大于指定的精度的主要内容,如果未能解决你的问题,请参考以下文章

ORA-01438 错误

捕获导致 ORA-01438 的列:值大于此列允许的指定精度

插入 3 时出现“ORA-01438: 值大于此列允许的指定精度”

插入 3 时出现“ORA-01438: 值大于此列允许的指定精度”

错误:“ORA-01438:值大于此列允许的指定精度”故障因素:“空”详细信息:org.kxml2.kdom.Node@99c0b9c

EBS_DBA_问题:关于ORA-01438: value larger than specified precision allowed for this column