Returning multiple result sets from server-side procedures in Postgres 11
you can return multiple result sets from a procedure - similar to the way it has always been possible with a function:

create procedure getdata(result_one inout refcursor, result_two inout refcursor)
as
$$
begin
  open result_one for 
    select * 
    from (values (1,2,3), (4,5,6)) as t(a,b,c);

  open result_two for 
    select * 
    from (values ('one'),('two'),('three'),('four')) as p(name);
end;
$$
language plpgsql;


However, displaying the results is a bit cumbersome - at least in psql:

postgres@localhost/postgres&gt; \set AUTOCOMMIT off

postgres@localhost/postgres&gt; call getdata(null, null);
     result_one     |     result_two
--------------------+--------------------
 &lt;unnamed portal 1&gt; | &lt;unnamed portal 2&gt;
(1 row)

postgres@localhost/postgres&gt; fetch all "&lt;unnamed portal 1&gt;";
 a | b | c
---+---+---
 1 | 2 | 3
 4 | 5 | 6
(2 rows)

postgres@localhost/postgres&gt; fetch all "&lt;unnamed portal 2&gt;";
 name
-------
 one
 two
 three
 four
(4 rows)

postgres@localhost/postgres&gt;


Some SQL clients can display the results automatically though.