| From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: could not find array type for data type character varying[] |
| Date: | 2009-10-28 15:36:48 |
| Message-ID: | 20091028153648.GR5407@samason.me.uk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Merlin Moncure | 2009-10-28 15:44:46 | Re: could not find array type for data type character varying[] |
| Previous Message | Alvaro Herrera | 2009-10-28 15:36:07 | Re: auto truncate/vacuum full |