concatenating strings from two different rows in a table

Posted by Azeem on Stack Overflow See other posts from Stack Overflow or by Azeem
Published on 2010-03-22T17:40:02Z Indexed on 2010/03/23 12:53 UTC
Read the original article Hit count: 306

Filed under:
|
|

Hello,

We are attempting to rework the SQL in a product. The product stores XML in a table as follows:

XML_STORAGE
- UID IDENTITY
- PARENT_ID INTEGER
- SEQ INTEGER
- XML VARCHAR(3800)

The current way of doing this is as follows:

Retrieve all ROWS for PARENT_ID = n. Then go over the fetched rows in the code and concatenate the XML strings into one large XML before parsing. The SEQ column is used to ORDER the result so the XML strings can be concatenated properly. Hopefully that is clear.

What we are attempting to do is rework this so we can use a SQL variant to retrieve the whole string and just fetch one row back from DB2. Is there a DB2 function that will allow us to concatenate the string in all of these rows into one large string in the resultset. How would such a SQL look. Please let me know. Any help is much appreciated.

Thanks! - Azeem

© Stack Overflow or respective owner

Related posts about sql

Related posts about db2