From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | simon <simon(dot)litwan(at)wyona(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: merge result sets |
Date: | 2006-06-21 12:16:48 |
Message-ID: | 20060621121648.GE7859@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Jun 21, 2006 at 02:08:29PM +0200, simon wrote:
> > The aggregate stuff should work. something like:
> >
> > SET kategorie = (SELECT comma_aggregate(kategorie_bezeichnung) FROM ...)
> >
> > should do the trick.
> i just found
>
> CREATE FUNCTION comma_aggregate(text,text) RETURNS text AS ' SELECT CASE
> WHEN $1 <> '''' THEN $1 || '', '' || $2 ELSE $2 END; ' LANGUAGE sql
> IMMUTABLE STRICT; CREATE AGGREGATE comma (basetype=text,
> sfunc=comma_aggregate, stype=text, initcond='' );
>
> and this didn't work with the above mentioned querry.
>
> i actually never found any docu about how tor write custom function
> which takes a whole result set no matter how many rows.
Then you havn't looked very hard:
http://www.postgresql.org/docs/current/interactive/sql-createaggregate.html
You created an aggregate called "comma" so that's how you should call
it. This is really no different from the SQL standard min(), max() and
sum() functions.
SET kategorie = (SELECT comma(kategorie_bezeichnung) FROM ...)
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2006-06-21 12:22:04 | Re: minimizing downtime when upgrading |
Previous Message | Kenneth Downs | 2006-06-21 12:10:20 | Re: minimizing downtime when upgrading |