Re: push array to array - Mailing list pgsql-general

From Pavel Stehule
Subject Re: push array to array
Date
Msg-id CAFj8pRAUF3FOgcWDyA+ZvwcYORdrr7twPgttQ6RgaegCtAG70Q@mail.gmail.com
Whole thread Raw
In response to Re: push array to array  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: push array to array  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-general


2016-09-18 19:12 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
Hi


2016-09-18 18:46 GMT+02:00 Tjibbe <tjibbe@rijpma.org>:
'{{4,5},{8,3}}' + '{3,6}'

postgres=# select '{{4,5},{8,3}}'::int[] || ARRAY[[3,6]];
+---------------------+
|      ?column?       |
+---------------------+
| {{4,5},{8,3},{3,6}} |
+---------------------+
(1 row)


CREATE OR REPLACE FUNCTION public.array2d_append(integer[], integer[])
 RETURNS integer[]
 LANGUAGE sql
AS $function$
SELECT COALESCE($1 || ARRAY[$2], $1, $2);
$function$

postgres=# SELECT array2d_append('{{4,5},{8,3}}', '{3,6}');
+---------------------+
|   array2d_append    |
+---------------------+
| {{4,5},{8,3},{3,6}} |
+---------------------+
(1 row)


 

regards

Pavel

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: push array to array
Next
From: Pavel Stehule
Date:
Subject: Re: push array to array