postgresql - Postgres dynamic sql and list result -


i used execute(for dynamic sql) , setof(result returning list), wrong :(

create table test select 1 id, 'safd' data1,'sagd' data2 union select 2 id, 'hdfg' data1,'sdsf' data2;  create or replace function test2(a varchar) returns setof record $body$ declare x record; begin x in execute loop return next x; end loop; return; end; $body$ language 'plpgsql' volatile;  select * test2('select * test'); 

you have know in advance structure of returned record

select * test2('select * test') s(a int, b text, c text);  |  b   |  c    ---+------+------  1 | safd | sagd  2 | hdfg | sdsf 

or if returned set set of test table use akash's proposed solution.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -