title: Postgres plpgsql error when trying to create function
body: <p>Postgres 9.5.2</p>
  
  <p>Getting: </p>
  
  <pre><code>ERROR:  syntax error at end of input
  LINE 14: ...ast_modified_at, NEW.first_name, NEW.last_name);
  </code></pre>
  
  <p>for these statements in a psql shell, right after running <code>$$;</code>:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION customer_history_trigger() RETURNS trigger
      LANGUAGE plpgsql SECURITY DEFINER
      AS $$
  BEGIN
      NEW.last_modified_at = now();
      IF (TG_OP = 'UPDATE') THEN
          IF OLD.status IS DISTINCT FROM NEW.status or OLD.parent_id IS DISTINCT FROM NEW.parent_id
          or OLD.first_name IS DISTINCT FROM NEW.first_name or OLD.last_name IS DISTINCT FROM NEW.last_name
          or OLD.company IS DISTINCT FROM NEW.company or OLD.company_alias IS DISTINCT FROM NEW.company_alias
          THEN
              INSERT INTO customerhistory
                  (customer_id, modified_at, first_name, last_name)
              VALUES
                  (NEW.id, NEW.last_modified_at, NEW.first_name, NEW.last_name);
          END IF;
      ELSIF (TG_OP = 'INSERT') THEN
          INSERT INTO customerhistory
              (customer_id, modified_at, first_name, last_name)
          VALUES
              (NEW.id, NEW.last_modified_at, NEW.first_name, NEW.last_name);
      END IF;
      RETURN NEW;
  END;
  $$;
  </code></pre>
  
  <p>There's also a little arrow in the error pointing to the semicolon at the end of the line.  So clearly, it doesn't like the semi colon at the end of this line: <code>(NEW.id, NEW.last_modified_at, NEW.first_name, NEW.last_name);</code> but I can't figure out why.</p>