title: How to query and execute trigger on the same table
body: <p>Hope someone can help with this. I am new to triggers and I am trying to create a trigger that checks to see if the record being modified has a specific value.</p>
  
  <p>example
  I have a table called Filing that has a filing_id and a filing_status, I want to prevent someone from updating or deleting any records in that table has a filing_status="FILED".
  so if i have the following</p>
  
  <pre><code>Filing_id    Filing_status    Val
  ---------    -------------    ---
  0             Filed           X
  </code></pre>
  
  <p>If someone tried to modify Val the trigger should stop it
  I have created the following trigger:</p>
  
  <pre><code>CREATE or replace TRIGGER TRG_PREV_FILING
    BEFORE DELETE or UPDATE
    ON PF.FILING
    FOR EACH ROW
     declare
       rowcnt number;
     BEGIN
       SELECT COUNT(filing_id) INTO rowcnt FROM PF.FILING 
        where status = 'FILED'
         and  filing_id = :new.filing_id;
       if (rowcnt &gt; 0)
       then
        raise_application_error (-20100, 'You can not delete Or Update initial record');
       end if;
     END;
  </code></pre>
  
  <p>The problem I am facing is I am getting:ORA-04091 which is "Table Filing is mutating, Trigger/function may not see it"</p>
  
  <p>So basically I can't query on the same table that I am executing the trigger on? Is that the problem in my case and does anyone know a work around this?</p>
  
  <p>I appreciate any help</p>