0

I am having issues figuring out how to integrate namespaces to a where clause having xmlexists. The query is as below:

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"]'

);

Any clues would be highly appreciated.

1
  • Would it not be simpler to write WHERE sing_info_type = 'IATCode'? Commented Nov 7, 2016 at 14:44

1 Answer 1

2
   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)

For xmlns(default) use declare default element namespace "http.url.url". For other declare namespace xyz

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks AL. But now the code which is in a procedure is failing with FAIL:Others errorORA-19228: XPST0008 - undeclared identifier: prefix '.' local-name ''.
I do not know what i was thinking. I need to actually use the xmlexists functionality before the select, cause a where clause with the xmlexists will still make the select fail with no_data_found if the tag is missing from an xml. Can xmlexists be used with an IF clause to check if the data exists before going into the 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\ / In EXISTSNODE namespaces go as last paramter ,'xmlns:abc="url.abc" xmlns:xyz="url.xyz"'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.