更新前创建Elsif触发器时出错

时间:2016-02-09 03:47:08

标签: oracle triggers

我在Selisih列等于0时创建触发器,然后Status列变为'Partial'。如果QtyInternalUse列等于QtyRequested,则Status列为Completed,否则为Not Issued

   CREATE OR REPLACE TRIGGER TG_STATUSINREQ
    BEFORE UPDATE OR INSERT ON M_INTERNALREQUESTERLINE
    FOR EACH ROW
    BEGIN
    IF (:new.Selisih <> 0 ) THEN
       :new.Status := 'Partial';
    ELSIF :new.QtyInternalUse := :new.QtyRequested THEN
       :new.Status := 'Completed';
    ELSE
       :new.Status := 'Not Issued';
    END IF;
    END;

我已经尝试过执行它并出现

的错误
 PLS-00103: Encountered the symbol "=" when expecting one of the
         following:
         . ( * @ % & = - + < / > at in is mod remainder not rem then
         <an exponent (**)> <> or != or ~= >= <= <> and or like like2
         like4 likec between || indicator multiset member submultiset
         The symbol "* was inserted before "=" to continue.

我已尝试删除:中的=,但仍然无法正常工作。我怎样才能解决这个问题?

REVISION

我更新了逻辑和:=。触发器已创建,它是这样的:

BEGIN

IF (:new.QtyInternalUse = 0 ) THEN

   :new.Status := 'Not Issued';

ELSIF :new.QtyInternalUse = :new.QtyRequested THEN

   :new.Status := 'Completed';

ELSE

   :new.Status := 'Partial';

END IF;

END;

1 个答案:

答案 0 :(得分:1)

这应该很容易google-resolve。你还在这里。

ELSIF :new.QtyInternalUse := :new.QtyRequested THEN

您正在尝试比较但使用赋值运算符[:=]。使用等于[=]代替将解决您的问题。

ELSIF :new.QtyInternalUse = :new.QtyRequested THEN