array_append function is not working

此生再无相见时 提交于 2021-01-28 20:45:47

问题


I need to append an item to existed array in postgresql. I wrote this code (plpgsql function):

perform array_append (arrayA::integer[],id);

Since it didn't work I tried:

raise notice '%', arrayA;
perform array_append (arrayA::integer[],id);
raise notice '%', arrayA;

It gives:

NOTICE:  <NULL>
NOTICE:  <NULL>

Why the array isn't updated?


回答1:


PERFORM query discard the results. array_append doesn't update the array you specify in the first parameter. It only reads the its values.

You should change your code to:

select array_append (arrayA::integer[],id) into v_arrayA;


来源:https://stackoverflow.com/questions/34337175/array-append-function-is-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!