CREATE OR REPLACE PROCEDURE thinq_to_prod_selfservice (
nomtable IN VARCHAR2,
brandingid IN VARCHAR2,
txcustxsl IN VARCHAR2
)
IS
p_dir VARCHAR2(200):='d:\oracle\admin\THINQP53\UTL_FILE_DIR\';
p_file VARCHAR2(200):=nomtable || '_' || brandingid || '_' || txcustxsl;
doc xmldom.domdocument;
main_node xmldom.domnode;
root_node xmldom.domnode;
user_node xmldom.domnode;
item_node xmldom.domnode;
root_elmt xmldom.domelement;
item_elmt xmldom.domelement;
item_text xmldom.domtext;
CURSOR curssysttext
IS
SELECT ID_BRANDING, NM_CUSTXSL, TX_CUSTXSL
FROM selfservicecustomxsl
WHERE id_branding = brandingid AND nm_custxsl = txcustxsl;
BEGIN
doc := xmldom.newdomdocument;
-- create root element
main_node := xmldom.makenode (doc);
root_elmt := xmldom.createelement (doc, 'main');
root_node := xmldom.appendchild (main_node, xmldom.makenode (root_elmt));
FOR get_systtext_rec IN curssysttext LOOP
item_elmt := xmldom.createelement (doc, 'DATA_RECORD');
user_node := xmldom.appendchild (root_node, xmldom.makenode (item_elmt));
item_elmt := xmldom.createelement (doc, 'ID_BRANDING');
item_node := xmldom.appendchild (user_node, xmldom.makenode (item_elmt));
item_text := xmldom.createtextnode (doc, get_systtext_rec.id_branding);
item_node := xmldom.appendchild (item_node, xmldom.makenode (item_text));
item_elmt := xmldom.createelement (doc, 'NM_CUSTXSL');
item_node := xmldom.appendchild (user_node, xmldom.makenode (item_elmt));
item_text := xmldom.createtextnode (doc, get_systtext_rec.nm_custxsl);
item_node := xmldom.appendchild (item_node, xmldom.makenode (item_text));
item_elmt := xmldom.createelement (doc, 'TX_CUSTXSL');
item_node := xmldom.appendchild (user_node, xmldom.makenode (item_elmt));
item_text := xmldom.createtextnode (doc, get_systtext_rec.TX_CUSTXSL);
item_node := xmldom.appendchild (item_node, xmldom.makenode (item_text));
END LOOP;
-- write document to file using default character set from database
xmldom.writetofile (doc, p_dir || TO_CHAR (SYSDATE, 'yyyymmdd') || '_' || p_file || '.xml' );
-- free resources
xmldom.freedocument (doc);
END;
/
Partager