2016-11-16 111 views
0

我有一个像函数调用没有结果集

create or replace function getalltypes(name character varying(100)) 
returns setof docs as $BODY$ 

begin 
perform c.contenttypename from conttype c; 

end; 
$BODY$ LANGUAGE PLPGSQL; 

文档PostgreSQL的功能是

select getalltypes('') 

是越来越没有结果显示,我已经创建

create type docs as (contenttypename character varying(100)) 

类型。任何人都可以帮忙吗?

+1

您可能想要更改从contType c执行c.contenttypename;从contType c返回查询c.contenttypename; –

+0

@VaoTsun - 从contType c返回查询c.contenttypename;在'c'处显示错误。我改为'返回查询从conttype c选择c.contenttypename;'然后它工作。谢谢 –

回答

1

您没有任何return语句。这就是为什么你看不到任何结果。 PERFORMis used to evaluate the query and DISCARD the result 这就是为什么你应该将perform c.contenttypename from conttype c;更改为return query select c.contenttypename from conttype c;