gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 22:28:21 25 4
gpt4 key购买 nike

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

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.

最佳答案

假设第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_billlate_fee 列的定义,很难知道问题是否是 late_fee 的定义需要是否被更改或者计算的值是否大于您的预期并且需要更改算法。

关于oracle - ORA-01438: 值大于该列允许的指定精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12668374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com