Oracle 9i: PL/SQL XML Dump of a Query
6
Turns an Oracle 9i SQL Query into custom XML output.
CREATE OR REPLACE procedure dump_pcd AS
qryCtx DBMS_XMLGEN.ctxHandle;
result CLOB;
BEGIN
qryCtx := dbms_xmlgen.newContext ('SELECT * from employees;');
DBMS_XMLGEN.setRowTag(qryCtx, 'EMPLOYEE'); DBMS_XMLGEN.setMaxRows(qryCtx, 5);
LOOP
result := DBMS_XMLGEN.getXML(qryCtx);
EXIT WHEN DBMS_XMLGEN.getNumRowsProcessed((qryCtx)=0);
INSERT INTO temp_clob_tab VALUES(result);
END LOOP;
END dump_pcd;
<?xml version=1.0?>
<ROWSET>
<EMPLOYEE>
<EMPLOYEE_ID>30</EMPLOYEE_ID>
<LAST_NAME>SCOTT</LAST_NAME>
<SALARY>20000<SALARY>
</EMPLOYEE>
<EMPLOYEE>
<EMPLOYEE_ID>31</EMPLOYEE_ID>
<LAST_NAME>MARY</LAST_NAME>
<AGE>25</AGE>
</EMPLOYEE>
</ROWSET>






There are currently no comments for this snippet.