| From: | simon <simon(dot)litwan(at)wyona(dot)com> | 
|---|---|
| To: | Martijn van Oosterhout <kleptog(at)svana(dot)org> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: merge result sets | 
| Date: | 2006-06-21 13:12:45 | 
| Message-ID: | 1150895565.9156.16.camel@localhost.localdomain | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Mit, 2006-06-21 at 14:16 +0200, Martijn van Oosterhout wrote:
> 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,
thanks very much. you're right i should have read the docu harder. but
now everthing works fine.
you made my day.
simon
-- 
Simon Litwan                               simon(dot)litwan(at)wyona(dot)com
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Wes | 2006-06-21 13:38:35 | Re: Adding foreign key constraints without integrity | 
| Previous Message | Jan Wieck | 2006-06-21 13:08:14 | Re: GPL Licensed Files in 8.1.4 |