[postgis-users] Building a 2D Array
Stephen Woodbridge
woodbri at swoodbridge.com
Wed Dec 18 10:59:09 PST 2013
On 12/18/2013 1:12 PM, Nathaniel Hunter Clay wrote:
> Hi all,
>
> I am trying to build a dynamic 2d array of elements in plpgsql, however
> I am running in to the problem that plpgsql will not support dynamic
> allocation of 2d arrays. So how do you build a 2d array when you don't
> know what its size will be until runtime? Prefferably with in a nested
> for loops.
>
> Any help would be greatly appreciated!!
This will create and zero fill an array of 10 columns and 5 rows:
create aggregate array_agg(float8[])
(
sfunc = array_cat,
stype = float8[],
initcond = '{}'
);
select array_agg(array[row]) from
(select array_agg(0.0::float8) as row
from generate_series(1,10)
) as a,
generate_series(1,5) b;
-Steve
More information about the postgis-users
mailing list