xmlForest ( d.dname as "Name", d.loc as "Location" ),
xmlAttributes ( e.empno as "employeeNumber" ),
xmlForest( e.ename as "Name", e.job as "Title", e.mgr as "Manager", e.hiredate as "StartDate"),
xmlElement ( "Commission", e.comm )
from scott.emp e
where e.deptno = d.deptno
).extract('/*') as XML
from scott.dept d
Thanks for the response. I have couple of doubts - would you mind clearing these out for me please:
1. For Employee element, you've used XMLForest for a bunch of fields and then used XMLElement for Commission. Why is it so? Could we have added commision to the XMLForest only - what difference would it make as per coding standard (the output remains the same in both the cases).
2. The use of .extract('/*') - I executed the query without using this and the result was still the same. Can you please explain the benefit of using this.