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

时间:2012-10-01 06:22:31

标签: oracle plsql ora-01438

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

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.

1 个答案:

答案 0 :(得分:5)

假设第19行的陈述是

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

问题似乎是计算diff * late_apt_fine的结果对于late_fee表中的monthly_bill列来说太大了。根据传入的参数值,我们知道late_apt_fine为70.由于我们在发生错误时无法知道diff变量的值,因此我们不知道&#39} ; t知道late_feemonthly_bill列的定义,很难知道问题是late_fee的定义是否需要更改或计算值是否比你预期的要大,算法需要改变。