title: How to make a PG function and trigger from SQL syntax?
body: <p>I'm currently using this SQL syntax to update all records of one table after checking values in another table:</p>
  
  <pre><code>UPDATE schema.table1 AS c 
  SET field1 = 'SI'
  FROM schema.table2 AS s
  WHERE
  c.specie = s.diam20 AND c.specie IS NOT NULL AND c.circonf/PI() &gt;= 0.20
  OR
  c.specie = s.diam40 AND c.specie IS NOT NULL AND c.circonf/PI() &gt;= 0.40
  OR
  c.specie = s.diam60 AND c.specie IS NOT NULL AND c.circonf/PI() &gt;= 0.60
  OR
  c.specie = s.diam80 AND c.specie IS NOT NULL AND c.circonf/PI() &gt;= 0.80;
  </code></pre>
  
  <p>Sorry I'm a newbie so I'm trying to setup a trigger after each inserting or updating of table 1, that updates field1 values calling a PG function that is able to do as above.
  Could you please help me?
  Thanks in advance</p>