Return setof record (virtual table) from function

后端 未结 5 497
天命终不由人
天命终不由人 2020-11-29 01:35

I need a Postgres function to return a virtual table (like in Oracle) with custom content. The table would have 3 columns and an unknown number of rows.

I just could

5条回答
  •  盖世英雄少女心
    2020-11-29 02:10

    To those who have landed here looking for the MSSQL equivalent of creating a temp table and dumping out its records as your return... that doesn't exist in PostgreSQL :( - you must define the return type. There are two ways to do this, at the time of the function creation or at the time of the query creation.

    See here: http://wiki.postgresql.org/wiki/Return_more_than_one_row_of_data_from_PL/pgSQL_functions

提交回复
热议问题