Re: Concatenate results of a single column query

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
Cc: gsstark(at)mit(dot)edu (Greg Stark), pgsql-sql(at)postgresql(dot)org
Subject: Re: Concatenate results of a single column query
Date: 2004-04-19 13:45:38
Message-ID: 87k70c5bel.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Christoph Haller <ch(at)rodos(dot)fzk(dot)de> writes:

> Interesting feature, but I cannot find function array_append:
> ERROR: AggregateCreate: function array_append(integer[], integer) does not exist

It's new in Postgres 7.4

I think you could do this in 7.3 though, it would just be more awkward. Try ||
but I think that's new in 7.4 as well. Otherwise I think you would have to
pick out the upper bound of the array with array_dims and set the upper+1'th
element of the array.

If you're doing text you may want to go directly to a textual concatenation
like:

CREATE FUNCTION concat_agg_accum(text, text) RETURNS text
AS 'select $1 || '', '' || $2'
LANGUAGE sql IMMUTABLE STRICT;

CREATE AGGREGATE concat_agg (
BASETYPE = text,
SFUNC = concat_agg_accum,
STYPE = text
);

--
greg

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stijn Vanroye 2004-04-19 14:06:01 Re: three-way join
Previous Message Gary Stainburn 2004-04-19 12:47:28 three-way join