Serge posted this one not too long ago. Do a search in this group for
XMLAGG.
B.
Thanks Brian, Serge.
select xmlagg(xmlelement(NAME a, email_address)) FROM
advertising.recipients;
Gives me
Function not supported (Reason code = "58"). SQLSTATE=42997
:-(
Running DB2 Express 8.2.1 on SLES 8. Do I need to be installing XML
extenders or something?
Serge Rielau - 13 Mar 2006 22:23 GMT
> Thanks Brian, Serge.
>
[quoted text clipped - 8 lines]
> Running DB2 Express 8.2.1 on SLES 8. Do I need to be installing XML
> extenders or something?
Wrap it into XML2CLOB(...)
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Brian Tkatch - 15 Mar 2006 16:08 GMT
XML is an internal data type that is the required input for some
FUNCTIONs, and others output. However, it is not supported while
interfacing with the user.
The main FUNCTION is XMLAGG(), however, it requires the XML data typeas
its input, and outputs it as its datatype too. To make text into XML,
XMLElement() both changes the text to be XML and changes the data type
to XML. So much for the input. For the output, (as Serge pointed out)
XML2CLOB() turns it into a viewable data type.
Then you need to strip the XML tags (try select
substr(xml2clob(xmlelement(NAME a, email_address)), 1, 50) FROM
advertising.recipients; to see it). Which is <A> and </A> ("A" is the
NAME you specified.) So, REPLACE does that.
Finally, if you don't actually want a clob, SUBSTR() takes care of
that.
B.