title: Update a table with a trigger after update
body: <p>I have two tables</p>
  
  <pre><code> batch (batch_id,start_date,end_date,batch_strength,is_locked)
   sem (user_id,is_active,no_of_days)
  </code></pre>
  
  <p>I have executed the trigger procedure given below then update the table using query</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION em_batch_update()
    RETURNS trigger AS $em_sem_batch$
  BEGIN
  
  UPDATE batch set is_locked='TRUE'
  where (start_date
         + (select no_of_days from sem
            WHERE is_active='TRUE' and user_id='OSEM')
        ) &lt;= current_date;
  
  return NEW;
  
  END;
  $em_sem_batch$  LANGUAGE plpgsql;
  
  CREATE TRIGGER em_sem_batch
  BEFORE UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE em_batch_update();
  
  update em_batch set batch_strength=20 where batch_id='OD001C001B3';
  </code></pre>
  
  <p>Error occured:</p>
  
  <blockquote>
    <p>ERROR:  stack depth limit exceeded<br>
    HINT:  Increase the configuration parameter "max_stack_depth" (currently 2048kB),
    after ensuring the platform's stack depth limit is adequate.</p>
  </blockquote>