【问题标题】:xmlexists with namespace in Oraclexml 与 Oracle 中的命名空间一起存在
【发布时间】:2017-03-20 22:34:50
【问题描述】:

我在弄清楚如何将命名空间集成到具有 xmlexists 的 where 子句时遇到问题。查询如下:

SELECT sing_d1.sing_info_text1, sing_d1.sing_info_text2
FROM XMLTABLE(
      xmlnamespaces (
                       'http://www.abccompany.com/Canonical' AS "abc",
                       'http://abccompany.com/PmtInfo' AS "pmt",
                       'http://abccompany.com/CommonTypes' AS "cmn",
                       'http://www.w3.org/2001/XMLSchema-instance' AS "xsi"),
                   '/abc:abc/abc:Pmt/pmt:Payments/pmt:PayInfo/pmt:Single/pmt:SingAddInfo'
                    PASSING payXml
                    COLUMNS 
                                  sing_info_type VARCHAR2(4000)
                                  PATH 'cmn:AddInfoCmpType',
                                  sing_info_text1 VARCHAR2(4000)
                                  PATH 'cmn:AddInfoCmpText[1]',
                                  sing_info_text2 VARCHAR2(4000)
                                  PATH 'cmn:AddInfoCmpText[2]'
              )sing_d1
WHERE 
                       XMLExists(

                   '/abc:abc/abc:Pmt/pmt:Payments/pmt:PayInfo/pmt:Single/pmt:SingAddInfo[AddInfoCmpType = "IATCode"]'

);

任何线索将不胜感激。

【问题讨论】:

  • WHERE sing_info_type = 'IATCode'不是更简单吗?

标签: sql oracle xmltable oracle-xml-db


【解决方案1】:
   XMLExists('   declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance";
                declare namespace abc="http://www.abccompany.com/Canonical";
                        declare namespace pmt="http://abccompany.com/PmtInfo";
                        declare namespace cmn="http://abccompany.com/CommonTypes";
                          /abc:abc/abc:Pmt/pmt:Payments/pmt:PayInfo/pmt:Single/pmt:SingAddInfo[AddInfoCmpType = "IATCode"]' passing payXml)

对于 xmlns(默认)使用 declare default element namespace "http.url.url"。对于其他declare namespace xyz

【讨论】:

  • 谢谢 AL。但是现在程序中的代码失败并显示 FAIL:Others errorORA-19228: XPST0008 - undeclared identifier: prefix '.'本地名称''。
  • 我不知道我在想什么。我需要在选择之前实际使用 xmlexists 功能,如果 xml 中缺少标记,那么带有 xmlexists 的 where 子句仍然会使选择失败并显示 no_data_found。 xmlexists 是否可以与 IF 子句一起使用,以在进入 select 之前检查数据是否存在?
  • select case when XMLExists('/a/b' passing xmltype('<a><b></b></a>')) then 'YES' else 'NO' end into var from dual; / select EXISTSNODE(xmltype('<a><b></b></a>'), '/a/b') into var from dual\ /EXISTSNODE 命名空间作为最后一个参数,'xmlns:abc="url.abc" xmlns:xyz="url.xyz"'
猜你喜欢
  • 2014-10-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-11
  • 2016-11-21
  • 1970-01-01
相关资源
最近更新 更多