title: Return result of query from function in postgresql
body: <p>I have the query for example "select id, field1, field2 from table1" (id and field1 are integer and field2 is varchar) and I need call the query from function and return result as is.</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION get_all_record()
    RETURNS TABLE(id integer , field2 varchar(20)) AS
  $$                                                  
  BEGIN
      EXECUTE 'SELECT table1.id, table1.field2 FROM table1' INTO id, field2;
      RETURN;
  END;
  $$
    LANGUAGE plpgsql
  </code></pre>
  
  <p>but this solution returns only one record in one field. How can I correct it?</p>