postgresqlmultiple-resultsets

Can Postgres 13 stored procedures return multiple result sets similar to SQL Server?


I tried to search for it in the official docs but no luck. Can Postgres 13 stored procedures return multiple result sets similar to SQL Server?


Solution

  • If you mean to return a result set by executing a plain query - no, such syntax is not supported in PL/pgSQL.

    If you mean to return a result set by using a cursor - yes, PostgreSQL stored procedures can return cursors too.

    You can define multiple cursor output parameters: https://www.postgresql.org/docs/13/plpgsql-cursors.html