title: Trigger to delete column after update
body: <p>I made trigger to delete data if inserted or updated row got BLOCKED=0:</p>
  
  <pre><code>create  or replace  trigger DATA_SOURCE_delete_blocked
  after insert or update
  on DATA_SOURCE
  FOR EACH ROW
  WHEN (new.BLOCKED=0)
  BEGIN
    DELETE FROM DATA_SOURCE WHERE DATA_SOURCE_ID=:NEW.DATA_SOURCE_ID;
  end;
  </code></pre>
  
  <p>it works for insert (at least data not writed, but may be with errors), but for update it doesn't work because of mutating error: </p>
  
  <pre><code>04091. 00000 -  "table %s.%s is mutating, trigger/function may not see it"
  *Cause:    A trigger (or a user defined plsql function that is referenced in
             this statement) attempted to look at (or modify) a table that was
             in the middle of being modified by the statement which fired it.
  *Action:   Rewrite the trigger (or function) so it does not read that table.
  </code></pre>
  
  <p>Is there any easy ways to delete rows after insert/update w/o creating view's?</p>
  
  <p>UPDATE:
  Resolved my problem with compaund trigger:</p>
  
  <pre><code>CREATE  OR REPLACE  TRIGGER DATA_SOURCE_DELETE_BLOCKED
  FOR INSERT OR UPDATE ON DATA_SOURCE when (new.BLOCKED=0)
  COMPOUND TRIGGER
  ID1 NUMBER;
  AFTER EACH ROW IS
  BEGIN
    ID1:=:NEW.DATA_SOURCE_ID;
  END AFTER EACH ROW;
  AFTER STATEMENT IS
  BEGIN
     DELETE FROM DATA_SOURCE WHERE DATA_SOURCE_ID=ID1;
  END AFTER STATEMENT;
  END DATA_SOURCE_DELETE_BLOCKED;
  </code></pre>