-- In WHEN, NEW and OLD don't need the colon

-- Update docencia.cod_pro when profesor.cod_pro changes
CREATE OR REPLACE TRIGGER cascade_profesor_update
AFTER UPDATE ON profesor
FOR EACH ROW
WHEN (OLD.cod_pro <> NEW.cod_pro)
BEGIN
    UPDATE docencia
    SET cod_pro = :new.cod_pro
    WHERE cod_pro = :old.cod_pro;
END;
/

-- Delete entries from docencia when profesor is deleted
CREATE OR REPLACE TRIGGER cascade_profesor_delete
AFTER DELETE ON profesor
FOR EACH ROW
BEGIN
    DELETE FROM docencia
    WHERE cod_pro = :old.cod_pro;
END;
/
