title: AFTER UPDATE trigger on Postgresql with pl/sh language problem
body: <p>Based on the answers from <a href="https://stackoverflow.com/questions/43205594/running-system-command-with-argument-in-a-postgresql-function">Running system command with argument in a PostgreSQL function</a> and few days research and testing, I confirmed that PL/SH does not support getting new trigger data when UPDATE. So I decided to create one more table to get the NEW data when UPDATE.</p>
  <p>The flow is following:</p>
  <p>DB-A table1 (Logical Replicate)-&gt; DB-B table1 (after update trigger insert OR update)-&gt; DB-C table 2(after trigger fired) , WHEN update to server, in after update trigger function, I connect to DB-B table1 again to get the result following the primary key, I expect to get the NEW data which is the after updated data on DB-B table 1 but I still get the OLD data which is the data before update.</p>
  <p>Based on documentation of Postgres:</p>
  <p>The trigger can be specified to fire before the operation is attempted on a row (before constraints are checked and the INSERT, UPDATE, or DELETE is attempted); or after the operation has completed (after constraints are checked and the INSERT, UPDATE, or DELETE has completed); or instead of the operation (in the case of inserts, updates or deletes on a view).</p>
  <p>I am very confused because the after update trigger is fired after the UPDATE isn't  it?</p>
  <p>This is my code:</p>
  <pre><code>#!/bin/sh
  
  (   
      echo &quot;OPR=${PLSH_TG_OP}&quot;
      echo &quot;TB=${PLSH_TG_TABLE_SCHEMA}.${PLSH_TG_TABLE_NAME}&quot;
      
      tabledt=&quot;TBRD=&quot;
      for arg 
      do
          tabledt=&quot;$tabledt$arg &quot;
      done
      
      echo $tabledt
      echo $PLSH_TG_WHEN;
      
      echo $(PGPASSWORD=xxx psql testslave xx -X -At -c &quot;select * from table1 where id = $1&quot;)
      
      
  ) | /home/xx/test/transition
  </code></pre>
  <p>Please help and any suggestion? Thankyou.</p>