title: Get values from varying columns in a generic trigger
body: <p>I am new to PostgreSQL and found a trigger which serves my purpose completely except for one little thing. The trigger is quite generic and runs across different tables and logs different field changes. I found <a href="http://crafted-software.blogspot.com/2011/05/hoorah-i-was-able-to-complete-my.html" rel="nofollow">here</a>.</p>
  
  <p>What I now need to do is test for a specific field which changes as the tables change on which the trigger fires. I thought of using <code>substr</code> as all the column will have the same name format e.g. <code>XXX_cust_no</code> but the XXX can change to 2 or 4 characters. I need to log the value in the<code>XXX_cust_no</code> field with every record that is written to the history_ / audit table. Using a bunch of <code>IF</code> / <code>ELSE</code> statements to accomplish this is not something I would like to do.</p>
  
  <p>The trigger as it now works logs the <code>table_name</code>, <code>column_name</code>, <code>old_value</code>, <code>new_value</code>. I however need to log the <code>XXX_cust_no</code> of the record that was changed as well.</p>