【问题标题】:Oracle UpdateXML not accepting a valid xPathOracle UpdateXML 不接受有效的 xPath
【发布时间】:2017-03-21 00:39:17
【问题描述】:

我在 XMLTYPE 列中有一个 XML,如下所示:

<n:ROOT xmlns:app="http://company/acms/content/DocType" xmlns:n="http://company/acms/content/DocType">
   <Content>
      <Definition>
         <Code>DocType</Code>
         <Version>1</Version>
      </Definition>
      <DocType>
         <Info>
            <DocumentType>DocType</DocumentType>
            <DocumentClass>Other</DocumentClass>
            <CustomerID>12323423</CustomerID>
            <FinancialAccountID>12312312</FinancialAccountID>
            <MSISDN>34534534</MSISDN>
            <CustomerType>Consumer</CustomerType>
            <CustomerSubType>Consumer-Platinum</CustomerSubType>
            <FirstName>Name</FirstName>
            <ServiceType>ServiceType</ServiceType>
            <DocumentSource>BadValueHere</DocumentSource>
            <BoxReferenceNumber>BoxXXX</BoxReferenceNumber>
            <Industry>OTHERS</Industry>
            <CreationDate>2015-01-01</CreationDate>
            <DocumentID>6666</DocumentID>
            <CreatedBy>UBIX</CreatedBy>
            <DocumentOrigin>HD</DocumentOrigin>
            <Notes>Document location on File System: /path/to/doc.TIF</Notes>
            <Resource parseType="none">
               <URL>/path/filename.pdf</URL>
               <FileName>filename.pdf</FileName>
               <MimeType>image/tiff</MimeType>
            </Resource>
            <FileType>tiff</FileType>
         </Info>
         <Permissions>
            <GroupPermissions>
               <GroupName>99</GroupName>
               <Permissions>C</Permissions>
            </GroupPermissions>
            <GroupPermissions>
               <GroupName>30</GroupName>
               <Permissions>W</Permissions>
            </GroupPermissions>
            <GroupPermissions>
               <GroupName>66</GroupName>
               <Permissions>R</Permissions>
            </GroupPermissions>
         </Permissions>
      </DocType>
   </Content>
</n:ROOT>

现在我需要将 DocumentSource 元素更新为新值。

我尝试了以下查询:

SET CONTENT_DATA =  UPDATEXML(CONTENT_DATA,
   '/n:ROOT/Content/DocType/Info/DocumentSource/text()', 'Test')
where CONTENT_ID=6666;

但是,当我尝试运行它时,我得到了 Oracle 错误: SQL 错误:ORA-31013:无效的 XPATH 表达式 31013. 00000 - “无效的 XPATH 表达式” *原因:传递给函数的 XPATH 表达式无效。 *操作:检查 xpath 表达式是否有可能的语法错误。

UpdateXML 文档已启用:https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions205.htm 它谈到了指定命名空间的第 5 个元素,但我没有运气让它工作:( 关于如何在我的 Google 场景中使用它的示例绝对为零......

有高手可以帮忙吗?

【问题讨论】:

    标签: xml oracle xpath namespaces updatexml


    【解决方案1】:

    试试 xpath ://Content/DocType/Info/DocumentSource/text()

    【讨论】:

    • 抱歉,删除了旧评论 - 它不适用于选择提取,但它适用于 UPDATEXML! :) 为什么?我想更好地理解它...
    • 我不了解 Oracle 环境的任何细节(尽管我知道当开发团队变得太大时产生好的错误消息是多么困难......)。基本上 XPath 表达式的语法是可以的,所以最有可能出错的是命名空间前缀“n”没有绑定到任何 URI。因此,您要么需要了解这个特定的 XPath API 如何让您绑定命名空间前缀,要么需要以不需要任何命名空间绑定的方式重写表达式。 @svasa 采用了后一种方法,这种方法很懒,但在这种情况下效果很好。
    • 谢谢迈克尔。我知道这个错误与我昨天所有谷歌搜索的命名空间有关,但没有一个例子说明如何使用函数的第 5 个参数作为命名空间。更新查询运行缓慢.. 现在运行 2 小时,超过 1000 万条记录要更新。可能是因为没有命名空间指定的简单解决方法导致它变慢吗?
    • 更新操作失败:SQL 错误:ORA-04030:尝试分配 55600 字节时进程内存不足 (qmcxdDecodeIni,qmemNextBuf:Large Alloc) 04030. 00000 - “尝试时进程内存不足分配 %s 个字节 (%s,%s)" *原因:操作系统进程私有内存已耗尽 *操作:有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-19
    • 2020-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    相关资源
    最近更新 更多