gpt4 book ai didi

sql - 甲骨文 11g : XQuery results concatenated in a single SQLXML type

转载 作者:行者123 更新时间:2023-12-04 05:46:08 26 4
gpt4 key购买 nike

当我在 PL-SQL 中运行 XQuery 查询时使用

 SELECT XQUERY('...' RETURNING CONTENT) FROM DUAL

结果总是在包含 SQLXML 字段的单行单列中串联返回。

这对于返回元素序列的查询是不好的,对于返回文本节点序列的查询来说真的很讨厌。

有没有办法避免这种连接并为每个返回的项目获取一行?

谢谢,

埃里克

最佳答案

您要使用 XMLTable而不是 XQuery。

XMLTable maps the result of an XQuery evaluation into relational rows and columns. You can query the result returned by the function as a virtual relational table using SQL.



例如:
create table customer as
select 1 id, 'Smith' last_name from dual union all
select 2 id, 'Jackson' last_name from dual union all
select 3 id, 'Peters' last_name from dual;

SELECT * from XMLTable('
for $customer in ora:view("customer")/ROW
return $customer/LAST_NAME'
columns "last_name" varchar2(4000) path '/LAST_NAME');

last_name
---------
Smith
Jackson
Peters

关于sql - 甲骨文 11g : XQuery results concatenated in a single SQLXML type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10663351/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com