Search Postgresql Archives

Re: unnest on multi-dimensional arrays

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

 






2013/11/28 bricklen <bricklen@xxxxxxxxx>
On Wed, Nov 27, 2013 at 11:28 PM, Pavel Stehule <pavel.stehule@xxxxxxxxx> 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
Feel free to edit directly or suggest any changes to it.

+1

Pavel
 

Cheers,

Bricklen


[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