postgresql 中的函数调用 returns 无结果集
Function call in postgresql returns no resultset
我有一个类似
的postgresql函数
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;
docs 是我创建的类型
create type docs as (contenttypename character varying(100))
于
select getalltypes('')
没有显示结果。有人可以帮忙吗?
您没有任何 return 声明。这就是您看不到结果的原因。
PERFORM
is used to evaluate the query and DISCARD the result
这就是为什么您应该将 perform c.contenttypename from conttype c;
更改为 return query select c.contenttypename from conttype c;
.
我有一个类似
的postgresql函数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;
docs 是我创建的类型
create type docs as (contenttypename character varying(100))
于
select getalltypes('')
没有显示结果。有人可以帮忙吗?
您没有任何 return 声明。这就是您看不到结果的原因。
PERFORM
is used to evaluate the query and DISCARD the result
这就是为什么您应该将 perform c.contenttypename from conttype c;
更改为 return query select c.contenttypename from conttype c;
.