PostgreSQL函数返回数组

4
我有以下函数(使用Postgres 9.4):
create or replace function toto()  RETURNS text[] AS $$
  DECLARE
    threed text[];
  BEGIN
    select array (select tata from hello)  into threed;
    raise notice 'HERE %',threed;
    return threed;
  END;
$$ LANGUAGE plpgsql;

在创建方面没有问题,我在psql中运行函数,得到如下结果:

 select from toto();
 NOTICE:  HERE {055,056,057,058,059}
 --
 (1 row)

通知显示了正确的结果。我不明白的是为什么结果本身没有显示?我哪里错了吗? 非常感谢您提供的任何指针和帮助。


1
select toto() or select * from toto() - user330315
对我来说,UNNEST 很管用 SELECT * FROM UNNEST(toto()) - Camille
1个回答

2

很抱歉,是一个愚蠢的错误。我调用函数时写成了 select toto() 而不是 select * toto();

找了一整天才发现这个错误 :(


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接