为什么我不能在触发器中放入这样的条件?
CREATE OR REPLACE TRIGGER HDR_WEB_UPD
BEFORE UPDATE ON HDR_WEB_LATEST
FOR EACH ROW
BEGIN
IF :NEW.UPD_USR = 'MARS72' OR :NEW.UPD_USR ='ROHA' OR :NEW.UPD_USR ='TAJUL'
THEN
IF :NEW.STATUS = 2
THEN
IF :OLD.STATUS = 2 AND :NEW.VER_USR := :OLD.VER_USR
THEN
:NEW.status := :OLD.status;
:NEW.VER_DATE := :OLD.VER_DATE;
:NEW.VER_USR := :OLD.VER_USR;
ELSE
:NEW.VER_DATE := SYSDATE;
:NEW.VER_USR := :NEW.UPD_USR;
END IF;
END IF;
else
:NEW.UPD_USR := :OLD.UPD_USR;
:NEW.VER_DATE := :OLD.VER_DATE;
:NEW.VER_USR := :OLD.VER_USR;
:NEW.closed_date := :OLD.closed_date;
:NEW.CLOSE_USR := :OLD.CLOSE_USR;
:NEW.status := :OLD.status;
END IF;
END;
发现的错误是
错误(8,47):PLS-00103:期望一个符号时遇到符号“ =” 以下的: 。 (* @%&=-+ / / at in是mod余数 不是rem然后<>或!=或〜=> = <= <>等 ||之间的like2 like4 likec指标多集成员子多集 在“ =”之前插入符号“ *”以继续。
答案 0 :(得分:1)
条件需要评估为true,false或null。为此,您必须使用以下比较运算符之一:=,<,>,<=,> =,<>,!=,〜=,^ =,IS NULL,LIKE,BETWEEN,IN。
问题似乎在线,并且更正的行是IF :OLD.STATUS = 2 AND :NEW.VER_USR = :OLD.VER_USR
。修改后的触发器如下:
CREATE OR REPLACE TRIGGER HDR_WEB_UPD
BEFORE UPDATE ON HDR_WEB_LATEST
FOR EACH ROW
BEGIN
IF :NEW.UPD_USR = 'MARS72' OR :NEW.UPD_USR ='ROHA' OR :NEW.UPD_USR ='TAJUL'
THEN
IF :NEW.STATUS = 2
THEN
IF :OLD.STATUS = 2 AND :NEW.VER_USR = :OLD.VER_USR
THEN
:NEW.status := :OLD.status;
:NEW.VER_DATE := :OLD.VER_DATE;
:NEW.VER_USR := :OLD.VER_USR;
ELSE
:NEW.VER_DATE := SYSDATE;
:NEW.VER_USR := :NEW.UPD_USR;
END IF;
END IF;
ELSE
:NEW.UPD_USR := :OLD.UPD_USR;
:NEW.VER_DATE := :OLD.VER_DATE;
:NEW.VER_USR := :OLD.VER_USR;
:NEW.closed_date := :OLD.closed_date;
:NEW.CLOSE_USR := :OLD.CLOSE_USR;
:NEW.status := :OLD.status;
END IF;
END;