I have a question about my trigger that I'm trying to create between two tables. When one table is updated the other should be updated too, but I seem to be missing proper syntax.
CREATE OR REPLACE TRIGGER TRIG_DEPT_ONUPDATE
AFTER UPDATE OF DEPT_ID ON DEPARTMENT FOR EACH ROW
BEGIN
UPDATE TEAM
SET DEPT_ID = :NEW.DEPT_ID
WHERE TEAM.DEPT_ID = :NEW.DEPT_ID;
END;
/
I get errors on update ("integrity constraint (%s.%s) violated - child record found"), but using the code:
CREATE OR REPLACE TRIGGER TRIG_DEPT_ONUPDATE
AFTER UPDATE OF DEPT_ID ON DEPARTMENT FOR EACH ROW
BEGIN
UPDATE TEAM
SET DEPT_ID = :NEW.DEPT_ID;
END;
/
it changes every single row after an update, though only select few need the change. Should an If statement be worked in somehow?