title: Update field updated by trigger
body: <p>I have a table with multiple fields and an additional outofsync field.
  Created a trigger and trigger function to set outofsync field value to true before any update/insert.</p>
  
  <p>Trigger:</p>
  
  <pre><code>CREATE TRIGGER goods_update_outofsync
    BEFORE UPDATE
    ON goods
    FOR EACH ROW
    EXECUTE PROCEDURE tg_update_goods_outofsync();
  </code></pre>
  
  <p>Trigger function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION tg_update_goods_outofsync()
    RETURNS trigger AS
  $BODY$
      BEGIN
      NEW.outofsync=true;
      RETURN NEW;
      END;
      $BODY$
    LANGUAGE plpgsql VOLATILE
    COST 100;
  ALTER FUNCTION tg_update_goods_outofsync()
    OWNER TO postgres;
  </code></pre>
  
  <p>And now comes to a "simple" question I am not able to find answer: how to update manually outofsync field to false, because after each attempt it is automatically changed to true by trigger.</p>
  
  <p>EDIT:</p>
  
  <p>This almost works:</p>
  
  <pre><code>IF (NEW.outofsync = OLD.outofsync) THEN
      NEW.outofsync=true;
  END IF;
  </code></pre>
  
  <p>Except when value of outofsync field is already false and I want to set it to false, because it became true then...</p>
  
  <p>Thank you for your help in advance!</p>