From: | bricklen <bricklen(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: unnest on multi-dimensional arrays |
Date: | 2013-11-28 16:01:26 |
Message-ID: | CAGrpgQ95-U-xYSfma2W3yO_fXjVWYiJKbPdXe+F7z1sCU8icGQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Nov 27, 2013 at 11:28 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>wrote:
> Hello
>
> postgres=# CREATE OR REPLACE FUNCTION public.reduce_dim(anyarray)
> RETURNS SETOF anyarray
> LANGUAGE plpgsql
> AS $function$
> DECLARE s $1%type;
> BEGIN
> FOREACH s SLICE 1 IN ARRAY $1 LOOP
> RETURN NEXT s;
> END LOOP;
> RETURN;
> END;
> $function$;
> CREATE FUNCTION
>
> postgres=# select reduce_dim(array[array[1, 2], array[2, 3]]);
> reduce_dim
> ------------
> {1,2}
> {2,3}
> (2 rows)
>
Hi Pavel,
I hope you don't mind, I took the liberty of adding your nifty function to
the Postgresql Wiki at
https://wiki.postgresql.org/wiki/Unnest_multidimensional_array
Feel free to edit directly or suggest any changes to it.
Cheers,
Bricklen
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2013-11-28 16:03:37 | Re: unnest on multi-dimensional arrays |
Previous Message | Bruce Momjian | 2013-11-28 15:39:18 | Re: [GENERAL] pg_upgrade ?deficiency |