【发布时间】:2018-12-28 11:47:47
【问题描述】:
我有一个这样的查询-
WITH xtbl AS (SELECT xmltype ('<root>
<parent>
<item>
<item_detail>AAA</item_detail>
<item_amount>1000</item_amount>
</item>
<item>
<item_detail>BBB</item_detail>
<item_amount>2000</item_amount>
</item>
</parent>
</root>') AS xcol FROM dual)
SELECT xmlcast (
xmlquery ('root/parent/string-join[item/item_detail/text()]' PASSING xcol RETURNING CONTENT) AS VARCHAR2 (2000))
AS item_details
FROM xtbl;
虽然上面指定的示例包含一个节点,但在我的实际问题中,并不是每个<parent> 节点都将包含一个<item> 节点。因此,我无法使用this 答案中描述的 XMLTable 解决方案。
SELECT xmlcast(... 查询是我迄今为止尝试过的,但它不起作用。我的预期输出是这个-
ITEM_DETAILS
------------------
AAA 1000, BBB 2000
请建议我如何修改我的 XMLQuery。
【问题讨论】:
标签: oracle xpath oracle11g oracle-xml-db