Я создал два триггера, имя триггера 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;
Когда я создаю этот триггер, он показывает ошибку рядом с «ВЫПОЛНИТЬ».