Search Postgresql Archives

push array to array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would like to push an array at the end of an array. Like:
    '{{4,5},{8,3}}' + '{3,6}' > '{{4,5},{8,3},{3,6}}'

Is there an easy way to do? (i have version "9.1.23" on my shared hosting)

Now I have written a complex function with EXECUTE command-string...


CREATE OR REPLACE FUNCTION push_2d_array(numeric[],numeric[]) RETURNS numeric[] AS $$
DECLARE
_str text;
_arr numeric[];
BEGIN
IF $1 IS NULL THEN
RETURN ARRAY[$2];
ELSE
_str := 'SELECT ARRAY[';
FOR i in 1..array_upper($1,1) LOOP
IF i > 1 THEN _str := _str || ','; END IF;
_str := _str || 'ARRAY[' || $1[i][1] || ',' || $1[i][2] || ']';
END LOOP;
_str := _str || ', ARRAY[' || $2[1] || ',' || $2[2] || ']]';
EXECUTE _str INTO _arr ;
RETURN _arr;
END IF;
END
$$ LANGUAGE plpgsql;




--
+31 6 29401726
tjibbe@xxxxxxxxxx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux