Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> XML-HELP
I have the data in clob which has the parent_id and their child
information is stored as ALIAS.How do I read this child information
from the alias.
I have tried using the extract function but I will get the empty
string but it has the values....How do I read this ALIAS info ?Any one
can help me in this regard...
I will give the example as dept and emp
Data looks like the following
select d.deptno,'<?xml version="1.0"
encoding="UTF-8"?>'||xmlagg(xmlelement("EMPDATA",xmlelement("EMPNO",e.empno),
xmlelement("ENAME",e.ename))).getclobval() as "EMPINFO" from
scott.dept d,scott.emp e where d.deptno=e.deptno group by d.deptno
DEPTNO EMPINFO
---------- --------------------------------------------------------------------------------10 <?xml version="1.0"
20 <?xml version="1.0"
encoding="UTF-8"?><EMPDATA><EMPNO>7369</EMPNO><ENAME>SMITH</
ENAME></EMPDATA><EMPDATA><EMPNO>7902</EMPNO><ENAME>FORD</ENAME></EMPDATA><EMPDAT
A><EMPNO>7876</EMPNO><ENAME>ADAMS</ENAME></EMPDATA><EMPDATA><EMPNO>7788</EMPNO><
ENAME>SCOTT</ENAME></EMPDATA><EMPDATA><EMPNO>7566</EMPNO><ENAME>JONES</ENAME></E
MPDATA>
30 <?xml version="1.0"
encoding="UTF-8"?><EMPDATA><EMPNO>7499</EMPNO><ENAME>ALLEN</
DEPTNO EMPINFO
---------- --------------------------------------------------------------------------------ENAME></EMPDATA><EMPDATA><EMPNO>7698</EMPNO><ENAME>BLAKE</ENAME></EMPDATA><EMPDA TA><EMPNO>7654</EMPNO><ENAME>MARTIN</ENAME></EMPDATA><EMPDATA><EMPNO>7844</EMPNO
Now I would like to read each alias information for that particular deptno and store it in the child table.
I am getting this result...
SQL> select xmltype(empdata).extract('/DEPTDATA/alias/EMPNO/text()').getstringval()
from test_data;
XMLTYPE(EMPDATA).EXTRACT('/DEPTDATA/ALIAS/EMPNO/TEXT()').GETSTRINGVAL()
SQL> select xmltype(empdata).extract('/DEPTDATA/alias/ENAME/text()').getstringval() from test_data;
XMLTYPE(EMPDATA).EXTRACT('/DEPTDATA/ALIAS/ENAME/TEXT()').GETSTRINGVAL()
Can any one help how do I get this alias information for each deptno ...
Thanks for your time...
Nirup
Received on Thu Dec 02 2004 - 13:35:58 CST