From: | simon <simon(dot)litwan(at)wyona(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: merge result sets |
Date: | 2006-06-21 10:23:44 |
Message-ID: | 1150885424.9156.3.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mit, 2006-06-21 at 00:09 +0200, simon wrote:
> On Die, 2006-06-20 at 15:34 -0500, Bruno Wolff III wrote:
> > On Tue, Jun 20, 2006 at 12:06:24 +0200,
> > simon <simon(dot)litwan(at)wyona(dot)com> wrote:
> > > hi all
> > >
> > > i'm using postgres 7.3
> > >
> > > my problem is i want to build a helper table:
> > >
> > > UPDATE studienmodul_summary
> > > SET kategorie = (SELECT kategorie_bezeichnung
> > >
> > > if the SELECT gives back just one result row, everthing is easy. my
> > > problem is, there is sometimes more than one result row.
> > >
> > > is there a way to concatenate all result rows and insert them in one
> > > field?
> >
> > Yes. You can have the subselect call a custom aggregate function that does
> > this for you. Sample code for doing this has been posted on the list
> > multiple times and you should be able to find it in the archives.
>
> thanks for this hint i didn't konw about the custom aggregate function.
> i found comma_aggregate(text,text) amd similar examples.
> unfortunatly i didn't found something like comma_aggregate(SELECT...).
>
> is it possible to write an aggregate function that takes the result rows
> of any number and makes a long string out of it?
>
> it would be great if someone would have done something before and is
> willing to share.
> but hints where to find docu and/or howtos about writting
> customaggregate functions are also very welcom.
>
> simon
> >
or in other words, i just would like to know how to rewrite
SET kategorie = array_to_string ((SELECT ARRAY (SELECT
kategorie_bezeichnung
so it works in psql7.3 as well.
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 | Martijn van Oosterhout | 2006-06-21 10:34:58 | Re: merge result sets |
Previous Message | Martijn van Oosterhout | 2006-06-21 10:05:22 | Re: A slow query - Help please? |