Re: push array to array
От | Pavel Stehule |
---|---|
Тема | Re: push array to array |
Дата | |
Msg-id | CAFj8pRBW_EGXVkp4_+1LqsrHjZ88UD_5xB-9BHHXGj5V-5WkRQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: push array to array (Pavel Stehule <pavel.stehule@gmail.com>) |
Список | pgsql-general |
2016-09-18 19:15 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:
2016-09-18 19:12 GMT+02:00 Pavel Stehule <pavel.stehule@gmail.com>:Hi
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$
sorry
better
SELECT COALESCE($1 || ARRAY[$2], $1, ARRAY[$2]);
SELECT COALESCE($1 || ARRAY[$2], $1, ARRAY[$2]);
postgres=# SELECT array2d_append('{{4,5},{8,3}}', '{3,6}');
+---------------------+
| array2d_append |
+---------------------+
| {{4,5},{8,3},{3,6}} |
+---------------------+
(1 row)
regardsPavel
В списке pgsql-general по дате отправления: