title: referencing new Table as new_table not visible to the trigger function Postgresql
body: <p>I am new in Postgresql so this question may be dumb for you guys!
  I am tring to use the referenced tables in a trigger function, but some how the function doesn't seem to have access on the referenced alias (<code>new_table</code>) :</p>
  
  <pre><code>CREATE FUNCTION Function_Name()
  RETURNS TRIGGER AS
  $$
  BEGIN
      SELECT tbl.some_field INTO new_table.other_field
      from some_table as tbl;
      return null;
  END;
  $$ LANGUAGE PLPGSQL;
  </code></pre>
  
  <p>I am having this error:</p>
  
  <pre><code>"new_table.other_field" is not a known variable 
  </code></pre>
  
  <hr>
  
  <p>and here is the trigger code:</p>
  
  <pre><code>CREATE TRIGGER Trigger_Name 
  AFTER INSERT
  ON Table_Name
  REFERENCING NEW TABLE AS new_table
  FOR EACH ROW
  EXECUTE FUNCTION Function_Name();
  </code></pre>
  
  <p>The function code should be executed first and then the trigger's, so how could the function access the alias that is referenced <strong>later</strong> in the trigger defenition??</p>
  
  <p>and how to access the referenced table aliases in the function?</p>
  
  <p>Note: In my example I am tring to use the alias, so when I use <strong>NEW</strong> inplace of <strong>new_table</strong> the function is created successfully!</p>