代码之家  ›  专栏  ›  技术社区  ›  Walentyna Juszkiewicz a_horse_with_no_name

ORA-19100:应传递或返回关键字

  •  0
  • Walentyna Juszkiewicz a_horse_with_no_name  · 技术社区  · 7 年前

    我有一个包含XML数据的简单表

    create table emp
    (dept xmltype)
    

    以及其中的数据

    insert into emp values ('<dept bldg="101">
    <employee id="901">
        <name>
            <first>John</first>
            <last>Doe</last>
        </name>
        <office>344</office>
        <salary currency="USD">55000</salary>
    </employee>
    </dept>')
    
    
    insert into emp values ('<dept bldg="103">
    <employee id="902">
        <name>
            <first>Peter</first>
            <last>Pan</last>
        </name>
        <office>216</office>
        <phone>905-416-5004</phone>
        </employee>
    </dept>')
    
    
    
    insert into emp values ('<dept bldg="114">
    <employee id="903">
        <name>
            <first>Mary</first>
            <last>Jones</last>
        </name>
        <office>415</office>
        <phone>905-403-6112</phone>
        <phone>647-504-4546</phone>
        <salary currency="USD">64000</salary>
    </employee>
    </dept>')
    

    当我执行以下操作时,它抛出ORA-19100:传递或返回关键字

    select XMLCAST(XMLQUERY('$INPT_XML/dept/employee/office/text()' PASSING dept  
    AS "INPT_XML") AS VARCHAR(20))
    FROM emp;
    

    有人能帮我回答这个问题吗?

    2 回复  |  直到 7 年前
        1
  •  1
  •   thatjeffsmith    7 年前

    不确定您在做什么,但您的错误告诉您出了什么问题,您需要RETURNING CONTENT子句。

    SELECT
    XMLCAST(XMLQUERY('$INPT_XML/dept/employee/office/text()' PASSING dept AS "INPT_XML" RETURNING CONTENT) AS VARCHAR2(20) )
    

    发件人 emp;

    返回此输出:

    XMLCAST(XMLQUERY('$I
    --------------------
    344
    216
    415
    

    有关Oracle XML的详细信息和操作方法 here

        2
  •  0
  •   Walentyna Juszkiewicz a_horse_with_no_name    7 年前

    问题在于缺少返回内容条款。

    看来甲骨文是被迫使用它的。

    https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions236.htm#SQLRF06209

    返回的内容表明,XQuery评估的结果要么是XML 1.0文档,要么是符合XML 1.0语义的文档片段。