From XML To Query

Hi,
This is My problem:
I receive datas from an xml Feed and I always worked in this
way:
<cftry>
<!--- fetch data from web service --->
<cfhttp url="
http://www.............
method="get" charset="utf-8"/>
<cfset xmldata = cfhttp.fileContent>
<cftry>
<!--- extract data from XML document and convert to query
--->
<cfset lstColumns =
"KH,NH,KC,NC,KD,ND,KS,NS,KL,NL,KZ,NZ,LR"/>
<cfset q2 = queryNew(lstColumns)/>
<!--- <cfif isXml(cfhttp.fileContent)> avialable in
CF7 only --->
<cfset xmlObject = xmlParse(xmldata)/>
<cfloop index="i" from="1"
to="#arrayLen(xmlObject["ArrayOfHotelRoom"].xmlChildren)#">
<cfset queryAddRow(q2,1)/>
<cfloop index="ii" list="#lstColumns#">
<cfset
querySetCell(q2,ii,xmlObject["ArrayOfHotelRoom"].xmlChildren
[ii].xmlText)/>
</cfloop>
</cfloop>
<!--- </cfif> --->
<cfcatch type="any"> <!--- any errors return empty
result set --->
<cfset q2 = queryNew(lstColumns)/>
</cfcatch>
</cftry>
<cfcatch type="any">
<cfoutput>There has been an internal problem. Please
try again later</cfoutput>
<cfexit>
</cfcatch>
</cftry>
<!--- use QoQ to filter by hotel name --->
<cfquery name="q" dbtype="query">
select * from q2
where SH = 'A' <!--- only show available hotels --->
</cfquery>
NOW THE PROBLEM IS THAT I NEED NOW TO IMPROVE MY SYSTEM USING
A NEW VERSION OF THE XML CATALOGUE THAT NOW INCLUDE XML.CHILDREN:
THE NEW XML:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfHotelRoom xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns="
http://tempuri.org/xml/xmlService">
<HotelRoom>
<KH>717</KH>
<NH>Acanto Suites & Lounge</NH>
<KC>PDC</KC>
<NC>Playa del Carmen</NC>
<KD>16</KD>
<ND>Playa del Carmen</ND>
<KS>7E</KS>
<NS>Special Category</NS>
<KL>CENT</KL>
<NL>City</NL>
<KZ>1</KZ>
<NZ>The Yucatan Peninsula</NZ>
<LR>132.5000</LR>
<Rooms>
<RoomType>
<KR>VLLBR1</KR>
<NR>One Bedroom Villa</NR>
<MP>RO</MP>
<RR>132.5</RR>
<IP>0</IP>
<IL>0</IL>
<IN>0</IN>
<IF>0</IF>
<PH>0</PH>
<SH>A</SH>
</RoomType>
</Rooms>
</HotelRoom>
AS YOU SEE AFTER "LR" NOW I FIND OTHERS CHILDREN AND I DO
NOT HOW TO REDUCE MY NEW XML TO QUERY
Thank You
Andrea

Hi Charlie,
thanks for your fast answer. I try to figure out what's are
my doubts and need:
1) Yes it must to be a query because i need to filter data to
be shown in many different outputs.
2) I understand that it should be possible to create
something like 2 database table :
one for the Hotel and
one for Rooms with all the subitems( I confirm you that there
will be situations with more RoomType Item for each Rooms. My doubt
now is how I will be able to manage the query joining the 2 tables
when I miss a common date to show in the statement WHERE ( Example
: WHERE Hoteltable.#KH#( hotel ID ) = RoomsTable.#Here I will miss
the compare data that in the second table is not provided by the
xml#.
How will I be able to manage the query??????
I think this is our way but I am really lost at this level.
Of course the solutions with only one table with multiple
rows for each rooms type will create me problems in outputs results
. I will have results where the selection will not be the hotel but
the rooms type and will be inconvenient to receive dinamically 5
times the same hotel with the different rooms type details.
What I need is to receive each hotel only once with all the
roomstype details inside.
Thanks for your help
Andrea

Similar Messages

  • Sql query, from xml to nested table

    Hello!
    I have DB table: my_table
    It has 2 fields: file_id and file_data (it's clob with xml)
    I need to write query that returns info from xml using nested table (Oracle v.9)
    The number of rows witch will return query must be equal to number of files (file_id)
    Structure of XML:
    <?xml version = "1.0" encoding = "utf-8"?>
    <head>
    <AAA v1="a" v2="b">
    <BBB p1="1" p2="2"/>
    <BBB p1="3" p2="4"/>
    </AAA>
    <AAA v1="c" v2="d">
    <BBB p1="5" p2="6"/>
    <BBB p1="7" p2="8"/>
    <BBB p1="9" p2="0"/>
    </AAA>
    </head>
    I have query, witch works! but not optimally! each CLOB scaned 3 times - I want to scan it once!
    SELECT an.file_id,
    CAST(MULTISET(SELECT extract(VALUE(val2),'//@v1').getStringVal() v1,
    extract(VALUE(val2),'//@v2').getStringVal() v2,
    CAST(MULTISET(SELECT extract(VALUE(val3),'//@p1').getStringVal() p1,
    extract(VALUE(val3),'//@p2').getStringVal() p2,
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA/BBB[../@v1='||extract(VALUE(val2),'//@v1').getStringVal()||']'))) val3) AS T_VAL3) info
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA'))) val2) AS T_VAL2) head
    FROM (SELECT olr.*
    FROM my_table olr,
    TABLE (XMLSEQUENCE(XMLTYPE(file_data)).EXTRACT('/head'))) val1) an
    PLEASE, help me to rewrite this query!

    I assume you're using nested objects like these to hold the result?
    create type t_val3_rec as object ( p1 number, p2 number );
    create type t_val3 as table of t_val3_rec;
    create type t_val2_rec as object ( v1 varchar2(30), v2 varchar2(30), c1 t_val3 );
    create type t_val2 as table of t_val2_rec;
    /then this query should work :
    SELECT t.file_id
         , CAST(
             MULTISET(
               SELECT extractvalue(value(x1), '/AAA/@v1')
                    , extractvalue(value(x1), '/AAA/@v2')
                    , CAST(
                        MULTISET(
                          SELECT extractvalue(value(x2), '/BBB/@p1')
                               , extractvalue(value(x2), '/BBB/@p2')
                          FROM TABLE(XMLSequence(extract(value(x1), '/AAA/BBB'))) x2
                        AS t_val3
               FROM TABLE(XMLSequence(extract(value(x), '/head/AAA'))) x1
             AS t_val2
    FROM my_table t
       , TABLE(XMLSequence(extract(xmltype(t.file_data), '/head'))) x
    ;

  • Logical operation in xml path query

    Hello
    If I have this XML data
    <a>
    <b>
    <c>
         <d>United States</d>
         <f>1</f>
         <g>Creditcard</g>
         <h>Will ship only within country</h>
         <k>something</k>
    </c>
    <c>
         <d>United States</d>
         <f>2</f>
         <g>MasterCard</g>
         <h>international</h>
         <k>something</k>
    </c>
    <c>
         <d>United States</d>
         <f>2</f>
         <g>MasterCard</g>
         <h>international</h>
         <k>something</k>
    </c>
    <c>
         <d>United States</d>
         <f>2</f>
         <g>MasterCard</g>
         <h>international</h>
         <k>something</k>
    </c>
    <c>
         <d>United States</d>
         <f>2</f>
         <g>MasterCard</g>
         <h>international</h>
         <k>something</k>
    </c>
    </b>
    </a>
    and I have this query:
    Q1: //c[NOT [[[/d="United States" AND /f="1" AND /g="Creditcard"] OR h="Will ship only within country"]]]
    How to write xml/sql query for it to retrive THE COUNT of the result , count of "c"
    Q2: //c[NOT [[[/d="United States" AND /f="1" AND /g="Creditcard"] OR h="Will ship only within country"]]]/k
    How to write xml/sql query for it to retrive THE COUNT of the result , count of "c/k"
    Thank you

    For example :
    SQL> with sample_data as (
      2      select xmltype('<a>
      3      <b>
      4      <c>
      5           <d>United States</d>
      6           <f>1</f>
      7           <g>Creditcard</g>
      8           <h>Will ship only within country</h>
      9           <k>something</k>
    10      </c>
    11      <c>
    12           <d>United States</d>
    13           <f>2</f>
    14           <g>MasterCard</g>
    15           <h>international</h>
    16           <k>something</k>
    17      </c>
    18      <c>
    19           <d>United States</d>
    20           <f>2</f>
    21           <g>MasterCard</g>
    22           <h>international</h>
    23           <k>something</k>
    24      </c>
    25      <c>
    26           <d>United States</d>
    27           <f>2</f>
    28           <g>MasterCard</g>
    29           <h>international</h>
    30           <k>something</k>
    31      </c>
    32      <c>
    33           <d>United States</d>
    34           <f>2</f>
    35           <g>MasterCard</g>
    36           <h>international</h>
    37           <k>something</k>
    38      </c>
    39      </b>
    40      </a>') xmldoc
    41      from dual
    42  )
    43  select count(*)
    44  from sample_data
    45     , xmltable(
    46         '//c[not(((d="United States" and f="1" and g="Creditcard") or h="Will ship only within country"))]'
    47         passing xmldoc
    48       ) x ;
      COUNT(*)
             4

  • How do I reference columns in a report query from another report query?

    In Apex 3.1 it is possible to generate a report on more than one query. I have read that these queries can be correlated, but I cannot find how in the documentation.
    I go the Shared Components and create a new Report Query:
    select * from dept
    Then I click Add Query and I add:
    select * from emp
    How do I correlate these two queries (I want to join emp.deptno to dept.deptno) and have a nice hierarchicle XML-file.
    Is it possible in Apex 3.1?
    Dik Dral

    Dik,
    This type of query can't be build. The two queries are independent, you can't reference values in the first query from the second query. However you can reference page and application items - which won't help you all that much with this scenario though. You could also try combining the two queries into one, and then take care of the proper presentation in your template.
    Regards,
    Marc

  • How to get attribute from xml file

    I managed to grab all the info from xml, except the "url" attribute in <image type="poster" url="" size="mid" .../>. Any ideas?
    import java.io.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import java.net.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class XmlParser {
         ArrayList<Movie> myMovies;
         Document dom;
         public XmlParser(){
              //create a list to hold the movie objects
              myMovies = new ArrayList<Movie>();
         public void runExample(String adr, String tagName) {
              parseXmlFile(adr);
              parseDocument(tagName);
              printData();          
         private void parseXmlFile(String adr){
              //get the factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              try {               
                   //Using factory get an instance of document builder
                   DocumentBuilder db = dbf.newDocumentBuilder();
                   //parse using builder to get DOM representation of the XML file
                   URL xmlUrl = new URL(adr);
                   InputStream in = xmlUrl.openStream();
                   dom = db.parse(in);               
              }catch(ParserConfigurationException pce) {
                   pce.printStackTrace();
              }catch(SAXException se) {
                   se.printStackTrace();
              }catch(IOException ioe) {
                   ioe.printStackTrace();
         private void parseDocument(String tagName){
              //get the root elememt
              Element docEle = dom.getDocumentElement();
              //get a nodelist of <movie> elements
              NodeList nl = docEle.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   for(int i = 0 ; i < nl.getLength();i++) {
                        //get the movie element
                        Element el = (Element)nl.item(i);
                        //get the Movie object
                        Movie mov = getMovie(el);
                        //add it to list
                        myMovies.add(mov);
          * I take an movie element and read the values in, create
          * an Movie object and return it
          * @param movE
          * @return
         private Movie getMovie(Element movE) {
              String title = getTextValue(movE, "original_name");
              String year = getTextValue(movE, "released");
              String imdbId = getTextValue(movE, "imdb_id");
              double score = getDoubleValue(movE, "score");
              String overview = getTextValue(movE, "overview");
              String poster = movE.getAttribute("url");
              Movie mov = new Movie(title, year, imdbId, score, overview, poster);
              return mov;
         private String getTextValue(Element ele, String tagName) {
              String textVal = null;
              NodeList nl = ele.getElementsByTagName(tagName);
              if(nl != null && nl.getLength() > 0) {
                   Element el = (Element)nl.item(0);
                   textVal = el.getFirstChild().getNodeValue();
              return textVal;
          * Calls getTextValue and returns a int value
          * @param ele
          * @param tagName
          * @return int
         private int getIntValue(Element ele, String tagName) {
              //in production application you would catch the exception
              return Integer.parseInt(getTextValue(ele, tagName));
          * Calls getTextValue and returns a double value
          * @param ele
          * @param tagName
          * @return double
         private double getDoubleValue(Element ele, String tagName) {
              return Double.parseDouble(getTextValue(ele, tagName));
          * Iterate through the list and print the
          * content to console
         private void printData(){
              System.out.println("Total Movies: " + myMovies.size());
              Iterator it = myMovies.iterator();
              while(it.hasNext()) {
                   System.out.println(it.next().toString());
         public static void main(String[] args){
              //create an instance
              XmlParser xp = new XmlParser();
              //call run example
              xp.runExample("http://api.themoviedb.org/2.1/Movie.search/en/xml/apikey/Fight+Club+1999", "movie");
    }Here is the example xml file I used
    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
      <opensearch:Query searchTerms="Fight Club 1999"/>
      <opensearch:totalResults>1</opensearch:totalResults>
      <movies>
        <movie>
          <score>8.383284</score>
          <popularity>3</popularity>
          <translated>true</translated>
          <adult>false</adult>
          <language>en</language>
          <original_name>Fight Club</original_name>
          <name>Fight Club</name>
          <alternative_name>El Club de la Lucha</alternative_name>
          <type>movie</type>
          <id>550</id>
          <imdb_id>tt0137523</imdb_id>
          <url>http://www.themoviedb.org/movie/550</url>
          <votes>62</votes>
          <rating>8.4</rating>
          <certification></certification>
          <overview>A lonely, isolated thirty-something young professional seeks an escape from his mundane existence with the help of a devious soap salesman. They find their release from the prison of reality through underground fight clubs, where men can be what the world now denies them. Their boxing matches and harmless pranks soon lead to an out-of-control spiral towards oblivion.</overview>
          <released>1999-09-16</released>
          <images>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-original.jpg" size="original" width="1000" height="1500" id="4bc908ab017a3c57fe002f75"/>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-mid.jpg" size="mid" width="500" height="750" id="4bc908ab017a3c57fe002f75"/>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-cover.jpg" size="cover" width="185" height="278" id="4bc908ab017a3c57fe002f75"/>
            <image type="poster" url="http://hwcdn.themoviedb.org/posters/f75/4bc908ab017a3c57fe002f75/fight-club-thumb.jpg" size="thumb" width="92" height="138" id="4bc908ab017a3c57fe002f75"/>
            <image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-original.jpg" size="original" width="1280" height="720" id="4bc908ab017a3c57fe002f71"/>
            <image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-poster.jpg" size="poster" width="780" height="439" id="4bc908ab017a3c57fe002f71"/>
            <image type="backdrop" url="http://hwcdn.themoviedb.org/backdrops/f71/4bc908ab017a3c57fe002f71/fight-club-thumb.jpg" size="thumb" width="300" height="169" id="4bc908ab017a3c57fe002f71"/>
          </images>
          <version>73</version>
          <last_modified_at>2010-09-11 14:33:06</last_modified_at>
        </movie>
      </movies>
    </OpenSearchDescription>

    pvujic wrote:
    Thanks, but how can I "fetch" the url from the image element?You've got to first get to the image element. But based on what you've posted though, with a little more coding, you should be able to succeed. Just give it a try! :)

  • How to remove elements/attributes from XML using Xpath in XSLT ??

    Hello ,
    Is there anyway or method of Xpath from which I can delete the elements and attributes from XML at runtime ??
    Like I have such XML and I have to remove per attribute highlighted below
    <person per="and">
    <e:emp a="ir" b="ad" >
    </e:emp>
    </person>
    And want a result like this
    <person>
    <e:emp a="ir" b="ad" >
    </e:emp>
    </person>
    Thanks

    To achieve this you can use the bpelx:remove function: http://download.oracle.com/docs/cd/E12483_01/integrate.1013/b28981/manipdoc.htm#CIHJBJFD
    your assign will look like:
    <bpel:assign>
    <bpelx:remove>
    <target variable="person" query="/person/@per" />
    </bpelx:remove>
    </bpel:assign>
    Regards,
    Melvin

  • Oracle XSU: oracle.xml.sql.query.OracleXMLQuery is not recognized

    Hi, there!
    I've got a problem when tryed to use Oracle XSU (xml-sql utility to generate xml). My simple java application works fine using XSU. But when I created session stateless bean I've got an EJBException regarding this
    line:
    oracle.xml.sql.query.OracleXMLQuery qry = new oracle.xml.sql.query.OracleXMLQuery(conn, commandSQLStatement);
    It doesn't recognize OracleXMLQuery class as I've got in dump. So my classpath includes original location of that utility and Oracle parser.
    I really appreciate for any help.
    Thanks.
    strXML = qry.getXMLString();

    Patricia,
    Did you go through the link
    Re: XML SQL Utility
    You have to put xsu12.jar in the lib directory of the jdev.
    xsu12.jar is in the lib directory of the XDK installation.
    You can download XDK from
    http://www.oracle.com/technology/tech/xml/xdk/software/prod/xdk_java.html
    Just download the XDK kit, get the xsu12.jar from the lib directory and put in the lib directory of the jdev.
    -- Arvind

  • Oracle.xml.sql.query.OracleXMLQuery   GetXML -withDTD

    I'm trying to create a dtd for each table in my schema. I've created a java program that loops through the user_tables and I am then trying to create the DTD with oracle.xml.sql.query.OracleXMLQuery -withDTD. I am able to make it work using the XSU Command Line Utility, but I'm having a hard time trying to find out where the -withDTD flag goes inside my java program. Anyone know how to use the -withDTD option inside of a java program?
    Thanks

    [from XmlRpc-Java]
    As a result, my XML
    is contained in a String instead of an InputStream.
    It is possible to convert a String to an InputStream using
    StringBufferInputStream, but this class is deprecated in favor of
    StringReader (as StringBufferInputStream does not properly convert
    characters into bytes).
    For the default HTTP transport, an InputStreamReader could be used to
    wrap the InputStream before calling parse().
    Ultimately, the InputStream is converted to an InputSource for use by
    the SAX parser. InputSource will accept a Reader as well.
    [from XmlRpc-Java]
    There should be a way to go from "getXMLString()" to "parse(Reader)" also. In the meantime I'm stuck.
    null

  • Oracle.xml.sql.query.OracleXMLQuery not found

    Hi!
    Sorry, but I got a project to continue and there is an import statement "import oracle.xml.sql.query.OracleXMLQuery;" and this gives me a compilation error...
    What do I need to do, where do I find this class??? Any help?
    //Patricia

    Patricia,
    Did you go through the link
    Re: XML SQL Utility
    You have to put xsu12.jar in the lib directory of the jdev.
    xsu12.jar is in the lib directory of the XDK installation.
    You can download XDK from
    http://www.oracle.com/technology/tech/xml/xdk/software/prod/xdk_java.html
    Just download the XDK kit, get the xsu12.jar from the lib directory and put in the lib directory of the jdev.
    -- Arvind

  • Oracle.xml.sql.query.OracleXMLQuery?

    Anyone know where I can find a java doc or any method infomation on:
    oracle.xml.sql.query.OracleXMLQuery
    thanks,
    chad.

    [from XmlRpc-Java]
    As a result, my XML
    is contained in a String instead of an InputStream.
    It is possible to convert a String to an InputStream using
    StringBufferInputStream, but this class is deprecated in favor of
    StringReader (as StringBufferInputStream does not properly convert
    characters into bytes).
    For the default HTTP transport, an InputStreamReader could be used to
    wrap the InputStream before calling parse().
    Ultimately, the InputStream is converted to an InputSource for use by
    the SAX parser. InputSource will accept a Reader as well.
    [from XmlRpc-Java]
    There should be a way to go from "getXMLString()" to "parse(Reader)" also. In the meantime I'm stuck.
    null

  • ORA-29540: class oracle/xml/sql/query/OracleXMLStaticQuery does not exist

    I am getting below error when trying to generate xml. Browsing on google did not help me. I would appreciate if someone can provide the solution.
    SQL> select dbms_xmlquery.getxml('select * from dual', 2) from dual;
    ERROR:
    ORA-29540: class oracle/xml/sql/query/OracleXMLStaticQuery does not exist
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 19
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 271
    ORA-06512: at line 1

    Then it is probably not the case that you are affected by the issue described in Metalink document 185857.1, but if I were you I would check it anyway, since it might be the problem.

  • Where is the oracle.xml.sql.query package?

    Hi,
    I have downloaded the xmlparser_v2_0_2_9.zip. I hoped I have everything to compile the example for retrieving XML document with an sql query. However, the jar file is missing the entire package oracle.xml.sql.query which contains for instance the crucial class OracleXMLQuery. Does anyone know where I could get this package - is it part of another download that I have to do, or can I buy it anywhere? Thanks for your help.
    Karel

    It's part of the XML SQL Utility for Java, avialable for download from http://technet.oracle.com/tech/xml

  • Problem in importing oracle.xml.sql.query.*

    When i am importing this
    import oracle.xml.sql.query.*;
    it is giving me error that
    "package oracle.xml.sql.query.* does not exist".
    What Should i install or set .

    [from XmlRpc-Java]
    As a result, my XML
    is contained in a String instead of an InputStream.
    It is possible to convert a String to an InputStream using
    StringBufferInputStream, but this class is deprecated in favor of
    StringReader (as StringBufferInputStream does not properly convert
    characters into bytes).
    For the default HTTP transport, an InputStreamReader could be used to
    wrap the InputStream before calling parse().
    Ultimately, the InputStream is converted to an InputSource for use by
    the SAX parser. InputSource will accept a Reader as well.
    [from XmlRpc-Java]
    There should be a way to go from "getXMLString()" to "parse(Reader)" also. In the meantime I'm stuck.
    null

  • Extracting data from XML using xmltype and extract

    Hello all,
    I want to write a pl/sql functions that takes a clob as an input and return a some data extracted from the data passed into it.
    the input will be an xml similar to the following:
    <FIXML xsi:schemaLocation="http://www.finacle.com/fixml executeFinacleScript.xsd" xmlns="http://www.finacle.com/fixml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Header>
            <ResponseHeader>
                <RequestMessageKey>
                    <RequestUUID>IVR201306180841060310000000000000000</RequestUUID>
                    <ServiceRequestId>executeFinacleScript</ServiceRequestId>
                    <ServiceRequestVersion>10.3</ServiceRequestVersion>
                    <ChannelId>IVR</ChannelId>
                </RequestMessageKey>
                <ResponseMessageInfo>
                    <BankId>01</BankId>
                    <TimeZone></TimeZone>
                    <MessageDateTime>2013-06-18T05:36:55.918</MessageDateTime>
                </ResponseMessageInfo>
                <UBUSTransaction>
                    <Id/>
                    <Status/>
                </UBUSTransaction>
                <HostTransaction>
                    <Id/>
                    <Status>SUCCESS</Status>
                </HostTransaction>
                <HostParentTransaction>
                    <Id/>
                    <Status/>
                </HostParentTransaction>
                <CustomInfo/>
            </ResponseHeader>
        </Header>
        <Body>
            <executeFinacleScriptResponse>
                <ExecuteFinacleScriptOutputVO>
                    <executeFinacleScript_customData>
                        <DataCategory>ACC</DataCategory>
                        <New_Data>0001019300101001</New_Data>
                    </executeFinacleScript_customData>
                </ExecuteFinacleScriptOutputVO>
            </executeFinacleScriptResponse>
        </Body>
    </FIXML>'
    I want to extract the value of new_data.
    I wrote the following anonymous block to test the code :
    declare
    xparam xmltype;
    v_xpath varchar2(500);
    begin
    xparam:=xmltype('<FIXML xsi:schemaLocation="http://www.finacle.com/fixml executeFinacleScript.xsd"  xmlns="http://www.finacle.com/fixml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Header>
            <ResponseHeader>
                <RequestMessageKey>
                    <RequestUUID>IVR201306180841060310000000000000000</RequestUUID>
                    <ServiceRequestId>executeFinacleScript</ServiceRequestId>
                    <ServiceRequestVersion>10.3</ServiceRequestVersion>
                    <ChannelId>IVR</ChannelId>
                </RequestMessageKey>
                <ResponseMessageInfo>
                    <BankId>01</BankId>
                    <TimeZone></TimeZone>
                    <MessageDateTime>2013-06-18T05:36:55.918</MessageDateTime>
                </ResponseMessageInfo>
                <UBUSTransaction>
                    <Id/>
                    <Status/>
                </UBUSTransaction>
                <HostTransaction>
                    <Id/>
                    <Status>SUCCESS</Status>
                </HostTransaction>
                <HostParentTransaction>
                    <Id/>
                    <Status/>
                </HostParentTransaction>
                <CustomInfo/>
            </ResponseHeader>
        </Header>
        <Body>
            <executeFinacleScriptResponse>
                <ExecuteFinacleScriptOutputVO>
                    <executeFinacleScript_customData>
                        <DataCategory>ACC</DataCategory>
                        <New_Data>0001019300101001</New_Data>
                    </executeFinacleScript_customData>
                </ExecuteFinacleScriptOutputVO>
            </executeFinacleScriptResponse>
        </Body>
    </FIXML>');
    v_xpath:='//New_Data/text()';-
    dbms_output.put_line(xparam.EXTRACT(v_xpath).GETSTRINGVAL());
    end;
    but I get the following Error:
    dbms_output.put_line(xparam.EXTRACT(v_xpath).GETSTRINGVAL());
    end;
    Error at line 1
    ORA-30625: method dispatch on NULL SELF argument is disallowed
    ORA-06512: at line 46
    the problem is that when I remove : xmlns="http://www.finacle.com/fixml" attribute from the root node the code works correctly.
    of course , I can simply use replace to remove it, but I want to know what is causing the error.
    I am using oracle database 10g

    Let me explain that the issue is not only related to Oracle.
    If you google a bit for default namespace and Xpath you will find many topic.
    Basically when you have an XML having a definition of namespace without a prefix:
    i.e.:
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Example XHTML document</title>
      </head>
      <body>
        <p>Sample content</p>
      </body>
    </html>
    this means that all unprefixed elements are belonging to this default namespace.
    In this case an Xpath equal to '//title/text()' will not get anything because it is assuming to find the element title within a null namespace. But title in this case is automatically assigned to the default namespace.
    When you specify a prefix in a namespace then all elements without prefix are associated to namespace NULL. Using a default namespace is causing a lot of headache.
    These links can be giving a clearer picture:
    http://www.edankert.com/defaultnamespaces.html
    Assuming that you have data like this:
    WITH mydata AS
    (   SELECT '
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>Example XHTML document</title>
      </head>
      <body>
        <p>Sample content</p>
      </body>
    </html>' xmldata FROM DUAL
    SELECT xmltype (xmldata).EXTRACT ('//title/text()').getstringval ()
      FROM mydata;
    This query will not give anything back to you. You will have to specify:
    SELECT xmltype (xmldata).EXTRACT ('//title/text()', 'xmlns="http://www.w3.org/1999/xhtml"').getstringval ()
      FROM mydata;
    Note also that you should be able to get the default namespace when it is specified (without prefix) by using:
    SELECT xmltype(xmldata).getnamespace() from mydata;
    Post your Oracle version to see if it something related to your version. In mine I got this:
    SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 20 18:32:58 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> WITH mydata AS
      2  (   SELECT '
      3  <html xmlns="http://www.w3.org/1999/xhtml">
      4    <head>
      5      <title>Example XHTML document</title>
      6    </head>
      7    <body>
      8      <p>Sample content</p>
      9    </body>
    10  </html>' xmldata FROM DUAL
    11  )
    12  SELECT xmltype(xmldata).getnamespace() from mydata;
    XMLTYPE(XMLDATA).GETNAMESPACE()
    http://www.w3.org/1999/xhtml
    SQL>
    If this would work, then it would be enough to add the optional additional parameter namespace. In case it is null it will be set as xmlsn="" and it will work anyway:
    Please note that it will work both if the XML has a default namespace or not
    i.e.:
    with default namespace:
    SQL> DECLARE
      2     xparam         XMLTYPE;
      3     v_xpath        VARCHAR2 (500);
      4     v_ns           VARCHAR2 (500);
      5  BEGIN
      6     xparam :=
      7        xmltype ('
      8  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ns="http://www.w3.org/1999/xhtml" >
      9    <head>
    10      <title>Example XHTML document</title>
    11    </head>
    12    <body>
    13      <p>Sample content</p>
    14    </body>
    15  </html>');
    16     v_xpath := '//title/text()';
    17     v_ns := 'xmlns="' || xparam.getnamespace () || '"';
    18     DBMS_OUTPUT.
    19      put_line (
    20        'Value of title:' || xparam.EXTRACT (v_xpath, v_ns).getstringval ());
    21  END;
    22  /
    Value of title:Example XHTML document
    PL/SQL procedure successfully completed.
    SQL>
    and without default namespace
    SQL> DECLARE
      2     xparam         XMLTYPE;
      3     v_xpath        VARCHAR2 (500);
      4     v_ns           VARCHAR2 (500);
      5  BEGIN
      6     xparam :=
      7        xmltype ('
      8  <html xmlns:ns="http://www.w3.org/1999/xhtml" >
      9    <head>
    10      <title>Example XHTML document</title>
    11    </head>
    12    <body>
    13      <p>Sample content</p>
    14    </body>
    15  </html>');
    16     v_xpath := '//title/text()';
    17     v_ns := 'xmlns="' || xparam.getnamespace () || '"';
    18     DBMS_OUTPUT.
    19      put_line (
    20        'Value of title:' || xparam.EXTRACT (v_xpath, v_ns).getstringval ());
    21  END;
    22  /
    Value of title:Example XHTML document
    PL/SQL procedure successfully completed.
    Regards.
    Al
    Message was edited by: AlbertoFaenza
    IF removed as it is working anyway.

  • SSMS 2012:XML File Query: Importing XML data using a CTE-Incorrect syntax near 'BLOB'?

    Hi all,
    From https://www.simple-talk.com/content/print.aspx?article=1756, I mimicked to create the following sql code to do Importing XML data using a CTE:
    ---Importing XML data using a CTE -----Ad-Hoc XML File Query--simple-talk---1020AM 27 Feb 2015
    ---query the XML Blob using a CTE (pulling from the XML file each time
    USE OPENXMLtesting1
    GO
    With XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'C:\XML FilesMicrosoft-Samples\books.xml', SINGLE BLOB) AS XmlData
    SELECT
    FROM XmlFile
    GO
    I got the following message:
    Msg 102, Level 15, State 1, Line 4
    Incorrect syntax near 'BLOB'.
    I have no ideas why it is incorrect in that code statment. Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang
    P. S. The books.xml file was copied from the Microsoft samples:
    <?xml version="1.0"?>
    <catalog>
    <book id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price>44.95</price>
    <publish_date>2000-10-01</publish_date>
    <description>An in-depth look at creating applications
    with XML.</description>
    </book>
    <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-12-16</publish_date>
    <description>A former architect battles corporate zombies,
    an evil sorceress, and her own childhood to become queen
    of the world.</description>
    </book>
    <book id="bk103">
    <author>Corets, Eva</author>
    <title>Maeve Ascendant</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2000-11-17</publish_date>
    <description>After the collapse of a nanotechnology
    society in England, the young survivors lay the
    foundation for a new society.</description>
    </book>
    <book id="bk104">
    <author>Corets, Eva</author>
    <title>Oberon's Legacy</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2001-03-10</publish_date>
    <description>In post-apocalypse England, the mysterious
    agent known only as Oberon helps to create a new life
    for the inhabitants of London. Sequel to Maeve
    Ascendant.</description>
    </book>
    <book id="bk105">
    <author>Corets, Eva</author>
    <title>The Sundered Grail</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
    <publish_date>2001-09-10</publish_date>
    <description>The two daughters of Maeve, half-sisters,
    battle one another for control of England. Sequel to
    Oberon's Legacy.</description>
    </book>
    <book id="bk106">
    <author>Randall, Cynthia</author>
    <title>Lover Birds</title>
    <genre>Romance</genre>
    <price>4.95</price>
    <publish_date>2000-09-02</publish_date>
    <description>When Carla meets Paul at an ornithology
    conference, tempers fly as feathers get ruffled.</description>
    </book>
    <book id="bk107">
    <author>Thurman, Paula</author>
    <title>Splish Splash</title>
    <genre>Romance</genre>
    <price>4.95</price>
    <publish_date>2000-11-02</publish_date>
    <description>A deep sea diver finds true love twenty
    thousand leagues beneath the sea.</description>
    </book>
    <book id="bk108">
    <author>Knorr, Stefan</author>
    <title>Creepy Crawlies</title>
    <genre>Horror</genre>
    <price>4.95</price>
    <publish_date>2000-12-06</publish_date>
    <description>An anthology of horror stories about roaches,
    centipedes, scorpions and other insects.</description>
    </book>
    <book id="bk109">
    <author>Kress, Peter</author>
    <title>Paradox Lost</title>
    <genre>Science Fiction</genre>
    <price>6.95</price>
    <publish_date>2000-11-02</publish_date>
    <description>After an inadvertant trip through a Heisenberg
    Uncertainty Device, James Salway discovers the problems
    of being quantum.</description>
    </book>
    <book id="bk110">
    <author>O'Brien, Tim</author>
    <title>Microsoft .NET: The Programming Bible</title>
    <genre>Computer</genre>
    <price>36.95</price>
    <publish_date>2000-12-09</publish_date>
    <description>Microsoft's .NET initiative is explored in
    detail in this deep programmer's reference.</description>
    </book>
    <book id="bk111">
    <author>O'Brien, Tim</author>
    <title>MSXML3: A Comprehensive Guide</title>
    <genre>Computer</genre>
    <price>36.95</price>
    <publish_date>2000-12-01</publish_date>
    <description>The Microsoft MSXML3 parser is covered in
    detail, with attention to XML DOM interfaces, XSLT processing,
    SAX and more.</description>
    </book>
    <book id="bk112">
    <author>Galos, Mike</author>
    <title>Visual Studio 7: A Comprehensive Guide</title>
    <genre>Computer</genre>
    <price>49.95</price>
    <publish_date>2001-04-16</publish_date>
    <description>Microsoft Visual Studio 7 is explored in depth,
    looking at how Visual Basic, Visual C++, C#, and ASP+ are
    integrated into a comprehensive development
    environment.</description>
    </book>
    </catalog>

    I found the mistakes I made and I corrected them. The newly revised/corrected code is:
    USE OPENXMLtesting1
    GO
    With XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'C:\Temp\books.xml', SINGLE_BLOB) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    It worked: Results
         Contents
    1  <catalog><book.id="bk101"><author>Gambardella.M...
    If I clicked on this, I got a listing of the whole book.xml!!  I don't know what it means.  Please comment and respond.
    Thanks,
    Scott Chang

Maybe you are looking for