XQuery语法错误

时间:2015-07-15 15:00:44

标签: sql xml oracle

在Oracle 11gR2上,我需要检索XML文件的一部分并创建一个新文件:

SELECT XMLQUERY
    ('for $e in /edi_l/trader
    where $e//pod="XX999"
    order by $e
    return <pod>{$e}</pod>'
   passing MY_T.XML_FILE
returning content
)
FROM MYTABLE MY_T;

输出:

<pod><trader cdisp="AB1111">
<idimpp num="1234">
<hdr>
<odn>567</odn>
<pod>XX999</pod>
</hdr>
...
</idimpp>
</trader>
</pod>

如果我省略了标签

<pod></pod>
SELECT XMLQUERY
    ('for $e in /edi_l/trader
    where $e//pod="XX999"
    order by $e
    return {$e}
   passing MY_T.XML_FILE
returning content
)
FROM MYTABLE MY_T;

我收到错误:

ORA-19114: XPST0003
LPX-00801: XQuery syntax error at '{'
4       return {$e}
-              ^
19114. 00000 -  "XPST0003 - error during parsing the XQuery expression: %s"
*Cause:    An error occurred during the parsing of the XQuery expression.
*Action:   Check the detailed error message for the possible causes.
Error at Line: 30 Column: 6

为什么呢?

我需要检索数据而不创建新的外部标记。

0 个答案:

没有答案