Hi,
I've got a problem in generating an XML
The XML is something like this :
<TAG1>
<TAG2>col</TAG2>
<TAG3>col</TAG3>
<TAG4>
...
</TAG4>
<TAG4>
...
</TAG4>
<TAG4>
...
</TAG4>
</TAG1>
where col are different columns of different tables and the <TAG4> ... </TAG4> section has to be created dinamically N times.
I've developed a package where I have a loop where I call a stored procedure to create <TAG4> ... </TAG4> and return this XML and to do every time something like this:
select xmlconcat(
v_xml_res,
p_xml_doc
).extract('/*')
into v_xml_res
from dual;
where v_xml_res is what I have already created and p_xml_doc is the new <TAG4> ... </TAG4> section generated, so as to have the
<TAG4>
...
</TAG4>
<TAG4>
...
</TAG4>
<TAG4>
...
</TAG4>
and to do the last part
select xmlelement("TAG1",
xmlelement("TAG2",col),
xmlelement("TAG3",col),
xmlconcat(
v_xml_res
)).extract('/*')
into v_xml_res
from tables, ...;
The problem is that when I try to concat the first two <TAG4> ... </TAG4> sections in an XMLTYPE, I got
ora-19010: cannot insert xml fragments
because in the loop the XML created would be:
<TAG4>
...
</TAG4>
<TAG4>
...
</TAG4>
<TAG4>
...
</TAG4>
that is not a well formed XML because I should have a external TAG but that I'm going to create only at the last step of the package.
How can I do?
Oracle version 10g
Thanks