title: pass parameter and reference in an update function in postgresql
body: <p>So I have a function <code>select_id_from_table(_t)</code>. It chooses certain column of the table (_t) where _t is a table name as a parameter. 
  I call it like <code>SELECT select_id_from_table('tablename')</code>.Now I want to create another function where the function does something like this:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION myfunction(_u type1, _t type2) returns void as $$
  BEGIN
  UPDATE (_u) set score=score+1 where _u.id in _t.id;
  END;
  $$ LANGUAGE plpgsql 
  </code></pre>
  
  <p>The problem is it can not pass the parameter properly. And also what should type1 and type2 be? _u and _t are both names of tables. I have tried:</p>
  
  <pre><code>$$begin
  create temp table lid as (select * from select_id_from_table(_t));
  execute format ('update '||quote_ident(_u) ||' set score= score+1 where 
  '||quote_ident(_u) ||'.id_ in (
  select * from select_id_from_table ('||quote_ident(_t)||') as 
  abc )');
  end;$$
  </code></pre>
  
  <p>I also tried creating a temp table, select <code>select_id_from_table(_t)</code>into that temp table and make reference of it later. But I still don't know how to quote it in <code>execute format('')</code>. Any ideas would be appreciated.  </p>