title: ORA-04091 table name is mutating in trigger due to cursor
body: <p>So when I compile the following script it throws the mutating table error:</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER SEND_MAIL
  BEFORE DELETE
  ON CATEGORIE
  FOR EACH ROW
  DECLARE 
  bodytext  varchar2(100);
  
  CURSOR getabonnee IS
  SELECT CATEGORIEABONNEMENT.MAILABONNEEID, NAAM 
  FROM CATEGORIE
  INNER JOIN CATEGORIEABONNEMENT ON CATEGORIEABONNEMENT.CATEGORIENAAM = CATEGORIE.NAAM
  WHERE NAAM = :old.NAAM;
  
  CURSOR getabonneeinfo(p_id CATEGORIEABONNEMENT.MAILABONNEEID%TYPE) IS
  SELECT MAILABONNEE.VOORNAAM, MAILABONNEE.ACHTERNAAM, MAILABONNEE.EMAILADRES
  FROM CATEGORIEABONNEMENT
  INNER JOIN MAILABONNEE ON MAILABONNEE.ID = CATEGORIEABONNEMENT.MAILABONNEEID
  WHERE MAILABONNEEID = p_id;
  
  BEGIN
  
     FOR cc IN getabonnee LOOP
  
        FOR cc2 IN getabonneeinfo(cc.MAILABONNEEID) LOOP
  
       bodytext := cc2.voornaam || cc2.achternaam || :old.NAAM;
       EXECUTE IMMEDIATE bodytext;
  
       SENDMAILABONNEE(bodytext, cc2.emailadres);
  
       DELETE FROM CATEGORIEABONNEMENT
       WHERE MAILABONNEEID = cc.MAILABONNEEID;
  
       UPDATE NIEUWSBERICHT
       SET CATEGORIENAAM = null
       WHERE CATEGORIENAAM = :old.NAAM;
  
    END LOOP;
  END LOOP;
  END;
  /
  
  savepoint deletecategory;
  
  delete from Categorie where naam='Buitenland';
  
  rollback to deletecategory;
  </code></pre>
  
  <p>I looked for solutions to this error and found that people suggest using a compound trigger. The problem is that for some reason, my database software (Oracle SQL Developer) doesn't recognize the compound trigger as a valid unit. I checked my oracle version and I have 11g so I don't quite understand why it won't work. Anyone has a solution for this problem?</p>