X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D8F52D1D08B for ; Mon, 19 Apr 2004 10:45:38 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 19777-08 for ; Mon, 19 Apr 2004 10:45:41 -0300 (ADT) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id 468CAD1B4BE for ; Mon, 19 Apr 2004 10:45:37 -0300 (ADT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 4ECDD17C4D7; Mon, 19 Apr 2004 09:45:39 -0400 (EDT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1BFZ5f-0003Rh-00; Mon, 19 Apr 2004 09:45:39 -0400 To: Christoph Haller Cc: gsstark@mit.edu (Greg Stark), pgsql-sql@postgresql.org Subject: Re: Concatenate results of a single column query References: <200404191315.PAA09557@rodos> In-Reply-To: <200404191315.PAA09557@rodos> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 19 Apr 2004 09:45:38 -0400 Message-ID: <87k70c5bel.fsf@stark.xeocode.com> Lines: 28 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/160 X-Sequence-Number: 17535 Christoph Haller 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