1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| create or replace PROCEDURE EXPORT_TO_XML AS
file_handle UTL_FILE.FILE_TYPE;
val_col1 HISTO_TRACA_INTERVENTION_E.ID_INTERVENTION%TYPE;
val_col2 HISTO_TRACA_INTERVENTION_E.ID_IPP%TYPE;
val_col3 HISTO_TRACA_INTERVENTION_E.ID_SEJOUR%TYPE;
xml_result CLOB;
BEGIN
FOR data IN (
SELECT
histo_traca_intervention_e.id_intervention,
histo_traca_intervention_e.id_ipp,
histo_traca_intervention_e.id_sejour,
histo_traca_intervention_e.id_histo AS id_histo1,
histo_traca_intervention_d.id_traca AS id_traca1,
histo_traca_intervention_d.id_ref_tracee AS id_ref_tracee1,
histo_traca_intervention_d.id_lot AS id_lot1,
histo_traca_intervention_d.dluo AS dluo1
FROM
histo_traca_intervention_e
INNER JOIN histo_traca_intervention_d ON histo_traca_intervention_e.id_intervention = histo_traca_intervention_d.id_intervention
WHERE
histo_traca_intervention_d.ID_HISTO = histo_traca_intervention_e.ID_HISTO
AND ID_IPP=lpad(ID_IPP,9,'0')
and histo_traca_intervention_e.date_cloture >= TO_DATE('2022-12-15', 'YYYY-MM-DD')
AND statut_historique <> 'INACTIF'
) LOOP
val_col1 := data.ID_INTERVENTION;
val_col2 := data.ID_IPP;
val_col3 := data.ID_SEJOUR;
SELECT XMLElement("Root",
XMLAgg(
XMLElement("data",
XMLForest(
histo_traca_intervention_e.id_intervention AS "HISTO_TRACA_INTERVENTION_E.ID_INTERVENTION",
ID_IPP AS "HISTO_TRACA_INTERVENTION_E.ID_IPP",
ID_SEJOUR AS "HISTO_TRACA_INTERVENTION_E.ID_SEJOUR",
histo_traca_intervention_e.id_histo AS "id_histo1",
histo_traca_intervention_d.id_traca AS "id_traca1",
histo_traca_intervention_d.id_ref_tracee AS "id_ref_tracee1",
histo_traca_intervention_d.id_lot AS "id_lot1",
histo_traca_intervention_d.dluo AS "dluo1"
)
)
)
).getClobVal()
INTO xml_result
FROM HISTO_TRACA_INTERVENTION_E,histo_traca_intervention_d
WHERE
HISTO_TRACA_INTERVENTION_E.ID_INTERVENTION = val_col1
AND HISTO_TRACA_INTERVENTION_E.ID_IPP = val_col2
AND HISTO_TRACA_INTERVENTION_E.ID_SEJOUR = val_col3;
file_handle := UTL_FILE.FOPEN('IMPORT', val_col1 || '_' || val_col2 || '_' || val_col3 || '.xml', 'W');
UTL_FILE.PUT_LINE(file_handle, xml_result);
UTL_FILE.FCLOSE(file_handle);
END LOOP;
END EXPORT_TO_XML; |
Partager