你能解决我的查询错误吗。非常感谢。
CREATE TABLE xml_tab ( id NUMBER, xml_data XMLTYPE );
INSERT INTO xml_tab VALUES(4,xmltype('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Jobsdata>
<jobList>
<jobData>
<job>
<name>JOBNAME10</name>
<document>
<fileID>100</fileID>
</document>
<document>
<fileID>1000</fileID>
</document>
<directoryid>D100</directoryid>
<schedule>
<frequency>IMMEDIATE</frequency>
</schedule>
<targetType>host</targetType>
<targets>
<name>node100.localdomain</name>
<type>host</type>
</targets>
<targets>
<name>node200.localdomain</name>
<type>host</type>
</targets>
</job>
</jobData>
<jobData>
<job>
<name>JOBNAME20</name>
<document>
<fileID>200</fileID>
</document>
<document>
<fileID>201</fileID>
</document>
<document>
<fileID>202</fileID>
</document>
<document>
<fileID>202</fileID>
</document>
<document>
<fileID>203</fileID>
</document>
<directoryid>D200</directoryid>
<schedule>
<frequency>REPEAT_BY_DAYS</frequency>
</schedule>
<status>ACTIVE</status>
<targetType>host</targetType>
<targets>
<name>node300.localdomain</name>
<type>host</type>
</targets>
</job>
</jobData>
<jobData>
<job>
<name>JOBNAME300</name>
<directoryid>D300</directoryid>
<schedule>
<days>3</days>
<days>5</days>
<frequency>WEEKLY</frequency>
</schedule>
<targets>
<name>node400.localdomain</name>
<type>host</type>
</targets>
</job>
</jobData>
</jobList>
</Jobsdata>'));
查询:
select id, x.*
from xml_tab, xmltable (
'Jobsdata/jobList/jobData/job' passing xml_data
columns
fileID path 'document/fileID',
directoryid path 'directoryid'
) x
;
给予
错误:ora-19025 extractvalue返回值
输出应为-
ID FILEID DIRECTORYID
4 100 D100
4 200 D200
4 201 D200
4 202 D200
4 203 D200
4 <null> D300
1条答案
按热度按时间lnlaulya1#
将作业节点之后的各个路径分开是很重要的
....job/document/fileID
与。....job/directoryid
在子查询联接期间,以及LEFT JOIN
应在其中添加条件name
列,而其余的联接则保留CROSS JOIN
和传统方法一样。因此,考虑使用:
演示