【发布时间】:2018-04-11 17:21:35
【问题描述】:
我想知道是否有人可以帮忙?
我正在尝试将一个 xml 文档中的所有元素(根级别以下)插入另一个。这两个文档都作为 XMLType 列驻留在 Oracle 12c 表中。我希望能够从他们的表中读取它们,执行转换,然后将其作为新文档写到表中。其中大部分内容都很简单,但我在执行插入的 XQuery 操作时遇到了问题……我天真地认为这很简单,但似乎无法做到正确。在 Oracle 12c 之前,我能够使用 appendchildxml 函数:
select
appendchildxml(my_output, '/Message', my_other_file, 'xmlns="SFA/ILR/2016-17"') into my_output
from
dual;
但该功能在 Oracle 12c 中已弃用,所以我现在需要使用 XQuery。
update xml_testing_12c
set
my_ilrxml =
XMLQuery('
xquery version "1.0";
copy $ilr := .
modify
insert nodes $dp_out/Destinations/node() as last into $ilr/Message
return $ilr
'
passing my_ilr, my_dpoutcome as "dp_out" returning content
)
where
run_number = (select max(run_number) from xml_testing_12c);
my_ilr 和 my_dpoutcome 是 PL/SQL XMLType 变量,包含我的有效 XML 文档。它们具有以下结构:
my_ilr 如下:
<Message xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="SFA/ILR/2016-17"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="SFA/ILR/2016-17">
<Header>
<CollectionDetails>
</CollectionDetails>
<Source>
</Source>
</Header>
<LearningProvider>
</LearningProvider>
<Learner>
<LearningDelivery>
</LearningDelivery>
</Learner>
</Message>
my_dpoutcome 如下:
<Destinations>
<LearnerDestinationandProgression>
<LearnRefNumber></LearnRefNumber>
<ULN></ULN>
<DPOutcome>
<OutType></OutType>
<OutCode></OutCode>
<OutStartDate></OutStartDate>
<OutCollDate></OutCollDate>
</DPOutcome>
</LearnerDestinationandProgression>
</Destinations>
父节点中有大量LearnerDestination和Progression元素。
我收到以下错误:
ORA-19112:评估期间出现错误: XVM-01155:[XUDY0027] 无效的目标表达式 ORA-06512:在第 286 行
任何帮助将不胜感激。
谢谢。
【问题讨论】: