title: Postgres insert or update trigger WHEN condition (old)
body: <p>I need write insert or update trigger, but with WHEN condition with compare OLD and NEW rows.</p>
  
  <p>According documentation OLD is null for insert operation. How i can use OLD in WHEN condition for INSERT AND UPDATE triggers?</p>
  
  <p>Example trigger:</p>
  
  <pre><code>CREATE TRIGGER mytrigger
      BEFORE INSERT OR UPDATE ON "mytable"
      FOR EACH ROW 
      WHEN (NEW.score &gt; 0 AND OLD.score &lt;&gt; NEW.score)
      EXECUTE PROCEDURE mytrigger();
  </code></pre>
  
  <p>but for insert OLD is null. </p>