ora-19025 extractvalue返回值错误

s4n0splo  于 2021-07-27  发布在  Java
关注(0)|答案(1)|浏览(464)

你能解决我的查询错误吗。非常感谢。

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
lnlaulya

lnlaulya1#

将作业节点之后的各个路径分开是很重要的 ....job/document/fileID 与。 ....job/directoryid 在子查询联接期间,以及 LEFT JOIN 应在其中添加条件 name 列,而其余的联接则保留 CROSS JOIN 和传统方法一样。
因此,考虑使用:

SELECT id, x3.*, x1.directoryid
  FROM xml_tab
  LEFT JOIN XMLTable(
                     'Jobsdata/jobList/jobData/job'
                     PASSING xml_data
                     COLUMNS directoryid VARCHAR2(100)  PATH 'directoryid',
                             name1       VARCHAR2(100)  PATH 'name'
 ) x1
 CROSS JOIN XMLTable(
                     'Jobsdata/jobList/jobData'
                     PASSING xml_data
                     COLUMNS fileID      XMLType       PATH 'job/document',          
                             name2       VARCHAR2(100) PATH 'job/name'
 ) x2 
 CROSS JOIN XMLTable(
                     'document/fileID'
                     PASSING x2.fileID
                     COLUMNS fileID      VARCHAR2(100)       PATH '.'
 ) x3
         ON name1 = name2

演示

相关问题