On Wed, Oct 28, 2009 at 04:17:32PM +0100, Viktor Rosenfeld wrote:
> I'm trying to aggregate a list of table attributes into an array.
I'd suggest using a tuple, arrays for things where each element means
the same thing. I'd guess you care about the substructure (i.e. the
element has a "namespace", a "name" and a "value") and hence using an
array in the first place seems wrong. Maybe something like:
CREATE TYPE foo AS ( namespace TEXT, name TEXT, value TEXT );
SELECT id, array_accum(row(a,b,c)::foo)
FROM data
GROUP BY id;
> Why doesn't this work?
Arrays of arrays aren't directly supported; you currently have to put
them into a tuple first. Something like:
CREATE TYPE bar AS ( a TEXT[] );
SELECT array_agg(row(array['a'])::bar);
--
Sam http://samason.me.uk/