Advertisement

06.01.2008 at 11:59PM PDT, ID: 23449055
[x]
Attachment Details

Using nested XMLAGG function in XML Type View in PL/SQL

Asked by Definit1 in Extensible Markup Language (XML), Oracle Database, PL / SQL

Tags: Oracle, PL/SQL Developer, Oracle 9.0, XML integration with PL/SQL

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_import_export_file",
        XMLELEMENT("file_header",
         XMLELEMENT("file_information")),
        XMLELEMENT("items",
         XMLELEMENT("documents",
          XMLELEMENT("document",
           XMLELEMENT("external_reference"),
           XMLELEMENT("processing_instructions",
            XMLELEMENT("update", name)),
           XMLELEMENT("filing_instructions",
            XMLELEMENT("folder_ids",
             XMLELEMENT("folder",
              XMLATTRIBUTES(folder_id AS "id", folder_type_id AS "folder_type_id")))),
           XMLELEMENT("document_header",
            XMLELEMENT("document_type",
             XMLATTRIBUTES(document_type AS "id")),
            XMLELEMENT("document_id", document_id),
            XMLELEMENT("document_description", document_description),
            XMLELEMENT("document_date",
             XMLATTRIBUTES(name AS "name"), document_date),
            XMLELEMENT("document_properties")),
           XMLELEMENT("document_data",
             XMLELEMENT("internal_file",
              (SELECT XMLAGG(XMLELEMENT("document_file_path", 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_export_file><file_header><file_information></file_information></file_header><items><documents><document><external_reference></external_reference><processing_instructions><update>False</update></processing_instructions><filing_instructions><folder_ids><folder id="UNKNOWN" folder_type_id="19"/></folder_ids></filing_instructions><document_header><document_type id="27"/><document_id>17882</document_id><document_description>Baker, Kenneth PR 12.07.doc</document_description><document_date name="Date of Service">2008-2-6</document_date><document_properties></document_properties></document_header><document_data><internal_file><document_file_path>\\adam\ADM Import XML Docs\ToDo\Baker, Kenneth PR 12.07.doc</document_file_path><document_extension>DOC</document_extension></internal_file></document_data></document></documents></items></macess_exp_import_export_file>

Regards,
Definit1Start Free Trial
[+][-]06.02.2008 at 10:29AM PDT, ID: 21693807

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 10:43AM PDT, ID: 21693896

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.02.2008 at 11:01AM PDT, ID: 21694016

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), Oracle Database, PL / SQL
Tags: Oracle, PL/SQL Developer, Oracle 9.0, XML integration with PL/SQL
Sign Up Now!
Solution Provided By: sdstuber
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.02.2008 at 12:07PM PDT, ID: 21694652

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.03.2008 at 07:16PM PDT, ID: 21706195

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 12:41PM PDT, ID: 21736592

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628