Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> aggregate string concat function, using xml

aggregate string concat function, using xml

From: <mycoward>
Date: Tue, 19 Oct 2004 21:31:01 +0800
Message-ID: <cl352a$mtd1@imsp212.netvigator.com>


the earliest sql aggregate concat discussion i have found dates back to 1997. i have been searching for quite a while. some code involves creating a type, using create type .... another pgsql solution requires the creation of a user-defined function.

select deptno, '' || xmlagg(xmlelement(a, ename)) from emp
group by deptno

i am looking for some easy, quick and dirty method.

what do you guys think about this code? this code returns all the names in each department. the names are concatenated into one xml string. further processing may be done with string substitution, regular expression, or xml parser

i tried the above code on a larger database and quickly hit the 4k string length limit. so i have used a clob to handle the long string

select deptno, xmlagg(xmlelement(a, ename)).getClobVal() from emp
group by deptno

i tested this in jdbc and it worked

and then i tried this 3rd sql

select '' || xmlagg(xmlelement(a, ename)) over(partition by deptno), emp.* from emp

i got ora-29400 data cartridge error

any idea? many thx Received on Tue Oct 19 2004 - 08:31:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US