为什么不从 Postgres 中的 refcursor 获取显示数据?

Why isn't fetch showing data from refcursor in Postgres?

知道为什么不显示数据吗?如何解决?

create or replace function test_refcursor(a refcursor) 
returns setof refcursor as
$$
begin
    open a for select from accounts;
    return next a;
end;
$$ language plpgsql;
begin;

然后尝试select数据:

mydb=> begin;
mydb=> select test_refcursor('a');
 test_refcursor
----------------
 a
(1 row)
mydb=> fetch all from a;
--
(58 rows)

最后一部分没有显示任何内容。它只是不支持这样的动态类型游标吗?

最后一部分不显示任何内容,因为您不需要任何内容​​。尝试:

...
open a for select * from accounts;
...