我使用EXECUTE(动态SQL)和SETOF(结果返回的列表),但它是错误的:(Postgres的动态SQL和列表结果
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行:select * from test2('select * from test'); ^ ********** **********错误 错误:需要一个字段定义列表返回 “记录” SQL国家职能:42601 字符:15 – Virus 2013-05-09 01:24:11