当我使用 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/