title: Accessing fields of records in triggers by column name passed as trigger arg
body: <p>I have a set of tables which make use of a discriminator column to make distinctions about entity type. Certain of those tables describe either relationships between defined groups of entities or contain more information for a particular type of entity. I want to have integrity checks on the data in the table. Originally these were written as checks but postgres does not handle table ordering in backups well so I thought to rewrite the checks as triggers so that I can turn off the triggers when restoring the database. </p>
  
  <p>Since the actual column name of entity will change from table to table and I would like to do it in a DRY fashion, I tried to write a single trigger function that took the id of the entity as an argument and verified that it was of the correct type. </p>
  
  <p>I am trying to call a function trigger that takes an argument </p>
  
  <pre><code>c.is_earth_based_measurement_tg(bigint).
  </code></pre>
  
  <p>The actual trigger is written as follows:</p>
  
  <pre><code>CREATE TRIGGER earth_based_measurement_locations_tg1
    BEFORE INSERT OR UPDATE
    ON measurements.earth_based_measurement_locations
    FOR EACH ROW
      EXECUTE PROCEDURE c.is_earth_based_measurement_tg(NEW.fk_measurement);
  </code></pre>
  
  <p>when I try to save the trigger, I get 'ERROR: syntax error at or near "."' referring to NEW.fk_measurement. What is the proper way to write this trigger?</p>
  
  <p>Thanks.</p>