In plpgSql, I need to add number to empty numeric array, this empty numeric array is variable.
What I do is this:
DECLARE
new_arr INTEGER[];
BEGIN
SELECT array_append(new_arr, 4) INTO new_arr;
This works, but I am not sure, may be exists better way for this?
new_arr := new_arr || 4is probably faster: adpgtech.blogspot.de/2014/11/assignment-beats-select-into.htmlselect. Plus I personally find:=more consistent within a procedural language than using aselectto assign a value.:=should be used there. But any assignment produce SELECT .. hidden, but SELECT. a := 1 and SELEC1 1 INTO a are same.