From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Florian Henge <florian(dot)henge82(at)web(dot)de> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: xml output |
Date: | 2010-08-23 12:09:05 |
Message-ID: | AANLkTikzQyUqXd_4_O9N0TtsbJ6b2wr8HgiRJAe8U6Gm@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 23 August 2010 12:33, Florian Henge <florian(dot)henge82(at)web(dot)de> wrote:
> hi there!
>
> i wanted to ask how to get an xml output from a table like this:
>
> <words>
> <first_name>joe</first_name>
> <first_name>ian</first_name>
> <first_name>carl</first_name>
> <first_name>ben</first_name>
> </words>
>
> what i have is the following:
>
> SELECT xmlelement(name words,
> xmlforest(nachname))
> FROM person
> SELECT
> xmlelement(name words,
> xmlforest(nachname))
> FROM person
>
> but that gives me this:
>
> <words><first_name>joe</first_name></words>
> <words><first_name>ian</first_name></words>
> <words><first_name>carl</first_name></words>
> <words><first_name>ben</first_name></words>
>
>
> thanks in advance!
>
> bye, flo
>
>
You need to use xmlagg:
SELECT
xmlelement(name words,
xmlagg(
xmlforest(first_name)
)
)
FROM person
Regards
--
Thom Brown
Registered Linux user: #516935
From | Date | Subject | |
---|---|---|---|
Next Message | san man | 2010-08-23 22:44:09 | select from pipe-delimited field |
Previous Message | Krzysztof Hoffmann | 2010-08-23 11:53:31 | Re: create a box from point? |