PL / SQL错误ORA-06550& PLS-00103在UPDATE语句中

时间:2013-12-06 03:12:19

标签: sql oracle plsql

我有以下代码。

CREATE OR REPLACE procedure BEFOR_VIP_RESET.CP_UPDATE_DTL_YHJ_SUM
is
cursor cur IS SELECT TRIM(DC.INV_NUM) INV_NUM,
                     SUM(DC.REDEEMVALUE) SUM_REDEEMVALUES 
              FROM DINV_COUPON DC 
              GROUP BY DC.INV_NUM;   
INT_COUNT_DINV_COUPON_BY_INV number;
begin
    for RUR1 in cur LOOP
        BEGIN
            SELECT COUNT(*) INTO INT_COUNT_DINV_COUPON_BY_INV 
            FROM DINV_DTL_YHJ DDY 
            WHERE TRIM(DDY.INV_NUM) = TRIM(RUR1.INV_NUM);

            IF (INT_COUNT_DINV_COUPON_BY_INV != 0) 
            THEN
                UPDATE DINV_DTL_YHJ D_D_Y 
                SET D_D_Y.REDEEMWAY = (RUR1.SUM_REDEEMVALUES/INT_COUNT_DINV_COUPON_BY_INV); --this error
            END IF;
        END;
    END LOOP;
end CP_UPDATE_DTL_YHJ_SUM;

错误讯息:

ORA-06550: line 12, column 27:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
. ( * @ % & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like 
  1. 调试时,我发现INT_COUNT_DINV_COUPON_BY_INVRUR1.INV_NUM的值正确。

  2. 当我改变时:

    UPDATE DINV_DTL_YHJ D_D_Y 
    SET D_D_Y.REDEEMWAY = (RUR1.SUM_REDEEMVALUES/INT_COUNT_DINV_COUPON_BY_INV);  
    
  3.     UPDATE DINV_DTL_YHJ D_D_Y 
        SET D_D_Y.REDEEMWAY = 66;    
    

    我也有同样的错误信息。

1 个答案:

答案 0 :(得分:1)

看起来好像忘记了WHERE声明中的UPDATE条款。这是故意的吗?

可能是这样的:

WHERE TRIM(DDY.INV_NUM) = TRIM(RUR1.INV_NUM);