问题
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