2013/11/28 bricklen <brick...@gmail.com>

> On Wed, Nov 27, 2013 at 11:28 PM, Pavel Stehule 
> <pavel.steh...@gmail.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.
>

+1

Pavel


>
> Cheers,
>
> Bricklen
>

Reply via email to