title: Postgres function with list argument and in clause
body: <p>How to create a function which takes as argument integer[] parameter and executing query with IN clause with this parameter in loop.
  In loop I want execute next select and result of this query I would like return.</p>
  
  <p>Something like that:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION function_which_i_want(my_argument integer[]) RETURNS my_schema_and_table[] AS
  $BODY$
  DECLARE
  result my_schema_and_table[];
  BEGIN
  FOR l IN SELECT * FROM table2 WHERE id in (my_argument) LOOP
  SELECT * FROM my_schema_and_table;
  END LOOP;
  END;
  ...
  </code></pre>
  
  <p>I want to get union of each select in loop. one huge joined result.
  Is this possible? Please help.</p>