How can output result of multi select in Function of Postgresql? -
i have function as:
create or replace function f_compare_data_extract(tm_id_1 integer,tm_subid_1 integer,tm_id_2 integer,tm_subid_2 integer ) returns integer $$ begin --select * a; --select * b; --select * c; return 0; end $$ language 'plpgsql' ;
i want output result of 3 query when run function : select f_compare_data_extract(13,2967,13,2968);
select * a; select * b; select * c;
postgresql doesn't support returning multiple result sets single command.
if selects a, b , c return data in same format, can union them together, return them 1 result set.
if return data in different formats, can still union them together, you'll need add lots of nulls.
alternatively, have function create , populate temporary tables. execute function , select temp tables in separate commands.
as final option, return data encoded somehow, e.g. using row_to_json
Comments
Post a Comment