title: Oracle After Update Trigger error
body: <p>I want to keep track of changes to one table in another table. What I need is an after update trigger which writes the name of changed column (if multiple columns are changed then there will be multiple inserts to the CHANGES table),the column's old and new values. How do I do that. I tried this but got an error after updating the table.So I'm giving you just the body.</p>
  
  <pre><code>IF :NEW.STAJYEAR!=:OLD.STAJYEAR THEN
   INSERT INTO X_STAJ (USERID,EDITDATE,CHANGEDCOLUMN,OLDVALUE,NEWVALUE)
   VALUES (:NEW.USERID,SYSDATE,'STAJYEAR',:OLD.STAJYEAR,:NEW.STAJYEAR);
  END IF;
  </code></pre>
  
  <p>the error code is :ORA-04098: trigger 'SYS.TR__TRACK_CHANGES' is invalid and failed re-validation</p>
  
  <pre><code>CREATE OR REPLACE TRIGGER STAJCHANGER.TR_TRACK_CHANGES
  AFTER UPDATE
  OF STAJYEAR
    ,STAJMONTH
    ,STAJDAY
  ON STAJCHANGER.STAJ 
  REFERENCING NEW AS New OLD AS Old
  FOR EACH ROW
  DECLARE
  OLDVALUE NUMBER;
  NEWVALUE NUMBER;
  COLUMNID NUMBER;
  
  
  BEGIN
  
  
     IF :NEW.STAJYEAR!=:OLD.STAJYEAR THEN
      INSERT INTO X_STAJ (USERID,EDITDATE,CHANGEDCOLUMN,OLDVALUE,NEWVALUE)
      VALUES (:NEW.USERID,SYSDATE,'STAJYEAR',:OLD.STAJYEAR,:NEW.STAJYEAR);
      END IF;
  
     IF :NEW.STAJMONTH!=:OLD.STAJMONTH THEN
      INSERT INTO X_STAJ (USERID,EDITDATE,CHANGEDCOLUMN,OLDVALUE,NEWVALUE)
      VALUES (:NEW.USERID,SYSDATE,'STAJMONTH',:OLD.STAJMONTH,:NEW.STAJMONTH);
      END IF; 
  
         IF :NEW.STAJDAY!=:OLD.STAJDAY THEN
      INSERT INTO X_STAJ (USERID,EDITDATE,CHANGEDCOLUMN,OLDVALUE,NEWVALUE)
      VALUES (:NEW.USERID,SYSDATE,'STAJDAY',:OLD.STAJDAY,:NEW.STAJDAY);
      END IF;
  
  END TR_TRACK_CHANGES;
  /
  </code></pre>