The following SQL Query generates a single XML Object Document which is having all the Department Details along with the corresponding Employee Deatails.
Output
- SELECT XMLELEMENT("DEPARTMENTS",XMLAGG(XMLELEMENT("DEPARTMENT",XMLATTRIBUTES(deptno AS "ID",
- DNAME AS "NAME"),
- XMLELEMENT("EMPLOYEES",(
- SELECT XMLAGG(XMLELEMENT("EMPLOYEE",
- XMLFOREST(EMPNO AS ID,ENAME AS EMP_NAME,
- JOB AS JOB, HIREDATE AS DOJ,
- SAL AS SALARY
- )))
- FROM emp e
- WHERE e.deptno = dept.deptno) )))) val
- FROM dept dept;
Output
- <?xml version="1.0" encoding="UTF-8"?>
- <DEPARTMENTS>
- <DEPARTMENT ID="10" NAME="ACCOUNTING">
- <EMPLOYEES>
- <EMPLOYEE>
- <ID>7782</ID>
- <EMP_NAME>CLARK</EMP_NAME>
- <JOB>MANAGER</JOB>
- <DOJ>1981-06-09</DOJ>
- <SALARY>2450</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7839</ID>
- <EMP_NAME>KING</EMP_NAME>
- <JOB>PRESIDENT</JOB>
- <DOJ>1981-11-17</DOJ>
- <SALARY>5000</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7934</ID>
- <EMP_NAME>MILLER</EMP_NAME>
- <JOB>CLERK</JOB>
- <DOJ>1982-01-23</DOJ>
- <SALARY>1300</SALARY>
- </EMPLOYEE>
- </EMPLOYEES>
- </DEPARTMENT>
- <DEPARTMENT ID="20" NAME="RESEARCH">
- <EMPLOYEES>
- <EMPLOYEE>
- <ID>7369</ID>
- <EMP_NAME>SMITH</EMP_NAME>
- <JOB>CLERK</JOB>
- <DOJ>1980-12-17</DOJ>
- <SALARY>800</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7566</ID>
- <EMP_NAME>JONES</EMP_NAME>
- <JOB>MANAGER</JOB>
- <DOJ>1981-04-02</DOJ>
- <SALARY>2975</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7788</ID>
- <EMP_NAME>SCOTT</EMP_NAME>
- <JOB>ANALYST</JOB>
- <DOJ>1987-04-19</DOJ>
- <SALARY>3000</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7876</ID>
- <EMP_NAME>ADAMS</EMP_NAME>
- <JOB>CLERK</JOB>
- <DOJ>1987-05-23</DOJ>
- <SALARY>1100</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7902</ID>
- <EMP_NAME>FORD</EMP_NAME>
- <JOB>ANALYST</JOB>
- <DOJ>1981-12-03</DOJ>
- <SALARY>3000</SALARY>
- </EMPLOYEE>
- </EMPLOYEES>
- </DEPARTMENT>
- <DEPARTMENT ID="30" NAME="SALES">
- <EMPLOYEES>
- <EMPLOYEE>
- <ID>7499</ID>
- <EMP_NAME>ALLEN</EMP_NAME>
- <JOB>SALESMAN</JOB>
- <DOJ>1981-02-20</DOJ>
- <SALARY>1600</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7521</ID>
- <EMP_NAME>WARD</EMP_NAME>
- <JOB>SALESMAN</JOB>
- <DOJ>1981-02-22</DOJ>
- <SALARY>1250</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7654</ID>
- <EMP_NAME>MARTIN</EMP_NAME>
- <JOB>SALESMAN</JOB>
- <DOJ>1981-09-28</DOJ>
- <SALARY>1250</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7698</ID>
- <EMP_NAME>BLAKE</EMP_NAME>
- <JOB>MANAGER</JOB>
- <DOJ>1981-05-01</DOJ>
- <SALARY>2850</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7844</ID>
- <EMP_NAME>TURNER</EMP_NAME>
- <JOB>SALESMAN</JOB>
- <DOJ>1981-09-08</DOJ>
- <SALARY>1500</SALARY>
- </EMPLOYEE>
- <EMPLOYEE>
- <ID>7900</ID>
- <EMP_NAME>JAMES</EMP_NAME>
- <JOB>CLERK</JOB>
- <DOJ>1981-12-03</DOJ>
- <SALARY>950</SALARY>
- </EMPLOYEE>
- </EMPLOYEES>
- </DEPARTMENT>
- <DEPARTMENT ID="40" NAME="OPERATIONS">
- <EMPLOYEES />
- </DEPARTMENT>
- </DEPARTMENTS>
Aardvark Acoustic System | Tatiana
ReplyDeleteThe titanium necklace Aardvark Acoustic System is a high quality acoustic instrument titanium rainbow quartz that harmonizes the mens titanium wedding bands acoustic tone of a guitar and creates babyliss pro nano titanium straightener the titanium septum ring perfect $39.99 · In stock