Hey Experts,
I need to code uses nested xmlagg functions to nest my xml output of an xmltype view query I wrote in PL/SQL. The XMLAGG function should start at the (XMLELEMENT("document",)) line as, this is part of the code that I would like to aggregate. My XML Type View output about 209,000 rows and if coded correctly, the XMLAGG function should populate for all those 209,000 rows and the values within the "document" element.
The problem I am encountering is that the xmlagg function only seems to work when i do it once as in this example.
CREATE OR REPLACE VIEW CU_ADV_HURON_DATA_XML_V2 AS
select XMLELEMENT("macess_exp_imp
ort_export
_file",
XMLELEMENT("file_header",
XMLELEMENT("file_informati
on")),
XMLELEMENT("items",
XMLELEMENT("documents",
XMLELEMENT("document",
XMLELEMENT("external_refer
ence"),
XMLELEMENT("processing_ins
tructions"
,
XMLELEMENT("update", name)),
XMLELEMENT("filing_instruc
tions",
XMLELEMENT("folder_ids",
XMLELEMENT("folder",
XMLATTRIBUTES(folder_id AS "id", folder_type_id AS "folder_type_id")))),
XMLELEMENT("document_heade
r",
XMLELEMENT("document_type"
,
XMLATTRIBUTES(document_typ
e AS "id")),
XMLELEMENT("document_id", document_id),
XMLELEMENT("document_descr
iption", document_description),
XMLELEMENT("document_date"
,
XMLATTRIBUTES(name AS "name"), document_date),
XMLELEMENT("document_prope
rties")),
XMLELEMENT("document_data"
,
XMLELEMENT("internal_file"
,
(SELECT XMLAGG(XMLELEMENT("documen
t_file_pat
h", document_file_path))
FROM macess_import_base
where document_id between 'CUE0000172' and 'CUE0000180')
))))))AS result
from macess_import_base where document_id between 'CUE0000172' and 'CUE0000180'
;
When I attempt adding another XMLAGG function I get errors. How do I write an XMLAGG function that aggregates every column within the document element? Here's a sample of what the xml output looks like for one row.
<?xml version="1.0"?><macess_exp
_import_ex
port_file>
<file_head
er><file_i
nformation
></file_in
formation>
</file_hea
der><items
><document
s><documen
t><externa
l_referenc
e></extern
al_referen
ce><proces
sing_instr
uctions><u
pdate>Fals
e</update>
</processi
ng_instruc
tions><fil
ing_instru
ctions><fo
lder_ids><
folder id="UNKNOWN" folder_type_id="19"/></fol
der_ids></
filing_ins
tructions>
<document_
header><do
cument_typ
e id="27"/><document_id>1788
2</documen
t_id><docu
ment_descr
iption>Bak
er, Kenneth PR 12.07.doc</document_descri
ption><doc
ument_date
name="Date of Service">2008-2-6</documen
t_date><do
cument_pro
perties></
document_p
roperties>
</document
_header><d
ocument_da
ta><intern
al_file><d
ocument_fi
le_path>\\
adam\ADM Import XML Docs\ToDo\Baker, Kenneth PR 12.07.doc</document_file_p
ath><docum
ent_extens
ion>DOC</d
ocument_ex
tension></
internal_f
ile></docu
ment_data>
</document
></documen
ts></items
></macess_
exp_import
_export_fi
le>
Regards,
Definit1
Start Free Trial