title: How to create the function in the postgresql to return the column value and update the table and also x locking the table?
body: <p>I have a table name xyz with single column C1 having the value 100 </p>
  
  <pre><code>CREATE OR REPLACE FUNCTION get_complaintID () 
     RETURN TABLE (
        complaintID VARCHAR
  ) 
  AS $$
  BEGIN
     RETURN QUERY SELECT
        complaintID
     FROM
        getcomplaint
  
  END; $$ 
  
  LANGUAGE 'plpgsql';
  </code></pre>
  
  <p>when i will call this function it should return the value 100 and also update the table with plus one e.g 100+1 every time when i call the function it should return the value of the table and also update the table value with one. After that it should apply the x lock on the table</p>