I have trigger:
CREATE OR REPLACE TRIGGER TR.TR_OUTPUT_EHT_UPDATE_OPE
AFTER DELETE
ON TR.TR_JN_OUTPUT_EHT
FOR EACH ROW
DECLARE
BEGIN
UPDATE TR.TR_BP tbp
SET tbp.DONE= 2, tbp.DATA_WYK = SYSDATE
WHERE EXISTS (SELECT ARCH.NR
FROM TR.TR_KB_OUTPUT_ARCH ARCH
WHERE ARCH.NR = tbp.NRKK)
AND NOT EXISTS (SELECT OUTPUT.NR_SERYJNY
FROM TR.TR_JN_OUTPUT OUTPUT
WHERE OUTPUT.NR = tbp.NRKK);
END;
/
After that I want to get the "NRKK" of just updated row and update another table which is connected by this "NRKK":
UPDATE P.TR_OPE OPE
SET OPE.DATA = SYSDATE,
OPE.STATUS = OPE.STATUS + 1
WHERE OPE.NRKK = "NRKK"
I tried to do:
SELECT tbp.NRKK INTO v_nrkk FROM TR.TR_BP tbp WHERE tbp.DATA = (SELECT
MAX(tbp.DATA) FROM TR.TR_BP tbp1);
but I have errors: ORA 04091, ORA 06512 and ORA 04088.
EDITED:
I created another trigger:
CREATE OR REPLACE TRIGGER TR.TR_OP_E
AFTER UPDATE ON TR.TR_BP
FOR EACH ROW
DECLARE
v_nrkk TR.TR_BP.NRKK % TYPE;
BEGIN
SELECT tbp.NRKK INTO v_nrkk FROM TR.TR_BPtbp WHERE tbp.DATA = (SELECT
MAX(tbp.DATA) FROM TR.TR_BP tbp1);
IF v_nrkk is NOT NULL THEN
UPDATE P.TR_OPE OPE
SET OPE.DATA = SYSDATE, OPE.STATUS = 1
WHERE OPE.ID_BR = '00100300'
AND OPE.NRKK = v_nrkk;
END IF;
END;
/
But I have still errors...