title: How to create a trigger that checks when one value is updated for defined values still being null and if not updates a table
body: <p>How can I create a trigger that is triggered by an update and then checks if there are certain values in the updated table and another table still null. If not it should change a value in a third table to sysdate.</p>
  
  <p>My code:</p>
  
  <pre><code>    CREATE OR REPLACE TRIGGER TRG_UPDATE_VALUE
          BEFORE UPDATE OF column1
          ON table1
      REFERENCING OLD AS OLD NEW AS NEW
          for each row
      DECLARE
          value_one_null int;
          value_two_null int;
  
      BEGIN
          SELECT COUNT(table1_id)
          INTO value_one_null
          FROM table1
          WHERE column1 IS NULL
          AND column2 = :NEW.column2;
  
          SELECT COUNT(table2_id)
          INTO value_two_null
          FROM table2
          WHERE column1 IS NULL
          AND column2 = :NEW.column2;
  
          IF (value_one_null = 0 AND value_two_null = 0)
              THEN
              UPDATE table3 SET table3.column1 = sysdate 
                  WHERE table3_id = :NEW.column2;
          END IF;
      END;
  
  </code></pre>
  
  <p>Compiling the trigger works. But if I try to update table 1 it errors ORA-04091, ORA-06512, ORA-04088</p>
  
  <p>I am a total beginner in PL/SQL so it would be amazing if someone could help me to fix this error.</p>