Postgres dynamic sql and list result
问题 I used EXECUTE(for dynamic sql) and SETOF(result is returning as list), but it is the wrong :( create table test as 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 as $BODY$ declare x record; begin for x in execute a loop RETURN NEXT x; end loop; return; end; $BODY$ LANGUAGE 'plpgsql' VOLATILE; select * from test2('select * from test'); 回答1: You will have to know in advance the structure of