我创建了两个触发器,触发器1名称TRIGGER_FOLLOWS_TEST_TRG_2
和触发器2名称TRIGGER_FOLLOWS_TEST_TRG_1
。
我希望通过重新创建TRIGGER_FOLLOWS_TEST_TRG_2
触发器来在TRIGGER_FOLLOWS_TEST_TRG_1
触发器之前执行TRIGGER_FOLLOWS_TEST_TRG_1
触发器。
create or replace TRIGGER TRIGGER_FOLLOWS_TEST_TRG_1
AFTER INSERT OR UPDATE
OF ISSA_STATUS_P, PRB_BEW_CODE
ON PROBE
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
EXECUTE TRIGGER_FOLLOWS_TEST_TRG_2
DECLARE
V_STATUS VARCHAR2(10);
V_BEW_CODE VARCHAR2(5);
BEGIN
IF INSERTING OR UPDATING THEN
V_STATUS := :NEW.ISSA_STATUS_P;
V_BEW_CODE := :NEW.PRB_BEW_CODE;
ELSE
V_STATUS := :OLD.ISSA_STATUS_P;
V_BEW_CODE := :OLD.PRB_BEW_CODE;
END IF;
IF (V_STATUS = 'PAF' AND V_BEW_CODE IS NULL) THEN
RAISE_APPLICATION_ERROR (-20011, 'Error: Status is finalized but assessment code is null');
END IF;
END TRIGGER_FOLLOWS_TEST_TRG_1;
和
create or replace TRIGGER TRIGGER_FOLLOWS_TEST_TRG_1
AFTER INSERT OR UPDATE
OF ISSA_STATUS_P, PRB_BEW_CODE
ON PROBE
DEFERRABLE INITIALLY DEFERRED
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
EXECUTE TRIGGER_FOLLOWS_TEST_TRG_2
DECLARE
V_STATUS VARCHAR2(10);
V_BEW_CODE VARCHAR2(5);
BEGIN
IF INSERTING OR UPDATING THEN
V_STATUS := :NEW.ISSA_STATUS_P;
V_BEW_CODE := :NEW.PRB_BEW_CODE;
ELSE
V_STATUS := :OLD.ISSA_STATUS_P;
V_BEW_CODE := :OLD.PRB_BEW_CODE;
END IF;
IF (V_STATUS = 'PAF' AND V_BEW_CODE IS NULL) THEN
RAISE_APPLICATION_ERROR (-20011, 'Error: Status is finalized but assessment code is null');
END IF;
END TRIGGER_FOLLOWS_TEST_TRG_1;
我已经尝试过了:
create or replace TRIGGER TRIGGER_FOLLOWS_TEST_TRG_1
AFTER INSERT OR UPDATE
OF ISSA_STATUS_P, PRB_BEW_CODE
ON PROBE
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
EXECUTE TRIGGER_FOLLOWS_TEST_TRG_2
DECLARE
V_STATUS VARCHAR2(10);
V_BEW_CODE VARCHAR2(5);
BEGIN
IF INSERTING OR UPDATING THEN
V_STATUS := :NEW.ISSA_STATUS_P;
V_BEW_CODE := :NEW.PRB_BEW_CODE;
ELSE
V_STATUS := :OLD.ISSA_STATUS_P;
V_BEW_CODE := :OLD.PRB_BEW_CODE;
END IF;
IF (V_STATUS = 'PAF' AND V_BEW_CODE IS NULL) THEN
RAISE_APPLICATION_ERROR (-20011, 'Error: Status is finalized but assessment code is null');
END IF;
END TRIGGER_FOLLOWS_TEST_TRG_1;
创建此触发器时,它在“ EXECUTE”附近显示错误。