PL/PgSQL calling a function inside a loop giving error

隐身守侯 提交于 2019-12-02 04:13:18

From the fine manual:

39.5.2. Executing a Command With No Result

[...]

Sometimes it is useful to evaluate an expression or SELECT query but discard the result, for example when calling a function that has side-effects but no useful result value. To do this in PL/pgSQL, use the PERFORM statement:

PERFORM query;

Emphasis mine. You're not calling the function by saying something like f();, you need to perform f(); or select f() into ...;:

for kv in select * from (select (each(extras)).*) as f(k,v) loop
    raise notice 'key=%,value=%',kv.k,kv.v;
    perform w_add_ax_extra(1, 'k', 'v');
end loop;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!