Oracle 9i: PL/SQL XML Dump Example





6
Date Submitted Sun. Sep. 24th, 2006 5:05 PM
Revision 1 of 1
Helper kahotep
Tags "oracle sql"
Comments 0 comments
The following procedure parses the fields in the employee table into XML and saves the XML as CLOB rows in a table.

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

        -- save the XML into the CLOB result.
        result :=  DBMS_XMLGEN.getXML(qryCtx);
        EXIT WHEN DBMS_XMLGEN.getNumRowsProcessed((qryCtx)=0);
 
        -- store the data to a temporary table
        INSERT INTO temp_clob_tab VALUES(result);

    END LOOP;
END dump_pcd;
 

chris c

Comments

There are currently no comments for this snippet.

Voting