pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Christoph Haller <ch@rodos.fzk.de>
Cc: gsstark@mit.edu
Cc: pgsql-sql@postgresql.org
Subject: Re: Concatenate results of a single column query
Date: 19 Apr 2004 09:45:38 -0400
Message-ID: <87k70c5bel.fsf@stark.xeocode.com> (raw)
In-Reply-To: <200404191315.PAA09557@rodos>
References: <200404191315.PAA09557@rodos>

Christoph Haller <ch@rodos.fzk.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




view thread (6+ messages)  latest in thread

Message-ID: <87k70c5bel.fsf@stark.xeocode.com>
Permalink:  ../87k70c5bel.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/87k70c5bel.fsf@stark.xeocode.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gsstark@mit.edu, ch@rodos.fzk.de
  Subject: Re: Concatenate results of a single column query
  In-Reply-To: <87k70c5bel.fsf@stark.xeocode.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox