Using namespaces in the XML QUERY

I need to included a namespace of i: in the query below.
the namespace is : "http://abc.com/int:i"
How can I include the namespace in the query below?
Is this possible?
SELECT XMLELEMENT("i:Trade", XMLELEMENT("i:Level",2.25),
                             XMLELEMENT("i:Style", 250),
                             XMLELEMENT("i:Size"),
                             XMLELEMENT("i:Block.Number"))
                FROM DUAL

What's wrong with Sundars answer in this Writing a Procedure to return back XML. Please help.?

Similar Messages

  • How to retrieve multiple columns using "returning" in the Insert query.

    hi,
    wanted to know how to retrieve multiple columns using "returning" in the Insert Query.
    For retrieving one column we write the query as follows:
    Insert into TABLE values(1,2,3,4) returning COLUMN1 into PARAMETER
    But can we retrive multiple columns in the same query?
    am using oracle 10g and coding in .NET

    Hi,
    You can definetely get multiple values from a single query using the 'returning' clause.
    Eg : insert into emp (empno, ename, job, deptno) values (7324,'ADAM','MARKETING',30) returning ename, deptno into var1, var2; PN : var1 & var2 to be declared as varchar2 & number respectively.
    More insight into the 'RETURNING' clause in this link.
    http://www.samoratech.com/PLSQL/swArtPLSQLReturn.htm
    Regards,
    Bhanu.

  • How to use XPath with Namespaces in the xml ?

    Hi all,
    I need to reference a certain Node in a Document using XPath notation.
    The problem is the the XML Document contains Namespaces inside it
    f.e.
    <xn:SubNetwork id="JRANM">
        <xn:VsDataContainer id="1">
           <xn:vsDataType>vsDataAreas</xn:vsDataType>
        </xn:VsDataContainer>
    </xn:SubNetwork >Using DOMXPath (from weblogic.xml.xpath)
      DOMXPath xPath = new DOMXPath("xn:SubNetwork/*");
      Set nodeset = xPath.evaluateAsNodeset(this.xmlRootElement);When I Iterate through the Set I can see it's empty.
    (On the other hand without namespaces everything is fine.)
    So how can I reference a Node that contains a namespace in it ?
    Thanks a lot
    Francesco

    We use the following class to perform XPath Queries on our XmlBean objects.
    Hope this helps,
    Craig
    import java.util.Set;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.apache.xmlbeans.XmlException;
    import org.w3c.dom.Document;
    import weblogic.xml.util.StringInputStream;
    import weblogic.xml.xpath.DOMXPath;
    * Class to encapsulate API specific (i.e. weblogic) XML functions
    public class XmlUtil {
         * Returns a set containing objects of type reflected in the query.<br/>
         * e.g.<br/>
         * /saur:tree/saur:treeNode[@label='My Reports']<br/>
         * Returns a Set of TreeNode objects<br/>
         * Sample Code: <br/>
         * <code>
         * Set set = XmlUtil.executeXPathQuery( myQuery, tree.xmlText());
         * for( Iterator iter = set.iterator(); iter.hasNext();) {
         *     TreeNode node = TreeNode.Factory.parse((Node)iter.next());
         *     // Do whatever...
         * </code>
         * @param query
         * @param xml
         * @return
        public static Set executeXPathSetQuery( String query, String xml) throws XmlException {
            try {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();   
                factory.setNamespaceAware(true);
                DocumentBuilder builder = factory.newDocumentBuilder();
                StringInputStream in = new StringInputStream(xml);
                Document doc = builder.parse(in);
                DOMXPath xQuery =  new DOMXPath(query);
                return xQuery.evaluateAsNodeset(doc);
            catch(Exception x) {
                throw new XmlException("Error running XPath query", x);
    }

  • Interesting Reqrmnt - How to avoid sending namespace in the xml response

    Hi,
    Below is the XML response we generate and send it to HTTP Receiver.
    - <ns1:CATSIMPORT xmlns:ns1="urn:pweh.com:erp:hr" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Version>1.0</Version>
      <TrackID>{5A3C87A5-48FD-4BCD-9178-A200F10F118D}</TrackID>
    - <ReturnCode>
      <value>Success</value>
      </ReturnCode>
      </ns1:CATSIMPORT>
    Can we remove the first and last line of the xml content and send it.
    Please send in your suggestions or answers.
    Regards,
    Amar Nemalikanti

    Hi Amareshwar,
    Check my replies in this link.
    just like java code to add a tag, you can use to remove a tag, before it goes to http adapter.
    Re: How to change the incoming xml to a different namespace
    Hope that helps you to fix your issue
    Regards
    Vishnu

  • How-to use Excel for the XML file input?

    Hello all,
    Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
    In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
    However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
    What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
    The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
    The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
    Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <MessageHeader>
        <CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
    </MessageHeader>
        <List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
        </List>
    </p:MySalesOrderUploadedIntegrationInputRequest>
    Thank you all for your attention.
    Best regards.
    Jacques-Antoine Ollier

    Hello Jacques-Antoine,
    I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
    But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
    Best regards,
    Leonid Granatstein

  • What application should i use to create the xml data as the input data for XFA template

    HI,
    I need to generate pdf or html document form from existing XDP with the given xml formatted data set. We usually use word to generate content for those XFA template, as the data should be in xml format content in word document should be able to convert into xml document that is compatible with XFA template. I want to know if there is any tool to conver word doument content to xml format that is compatible with XFA template or has adobe given their own tool to create content that comply with XFA template? . Also i want to know if i can do above mention functionality jaut with adobe forms if not what are the other services that i should use. Please give me the prices of adobe forms and any other tool that i should use. Thank you

    XFA is just the definition of the form template. Once you have an XFA based template, you can merge any XML you want.
    The trick is do the appropriate binding so the data from the XML goes in the right fields on your form. This binding is done using LiveCycle Designer.
    Jasmin

  • Using :APP_ID in the sql query in apex

    Hi All,
    I am facing problem while using :APP_ID in the query for populating the Select list in apex.
    can any one suggest me how to use :APP_ID in the query. It is working fine in URL making.... in the javascript codes.
    And one more thing please put up the list of Global variable, Environment Variables in apex. like :APP_USER, :APP_ID
    Thanks in Advance,
    Santhosh Tirunahari

    Hello Santhosh,
    An example using APP_ID:
    select WORKSPACE, APPLICATION_ID, APPLICATION_NAME, LIST_NAME
    from APEX_APPLICATION_LIST_ENTRIES
    where APPLICATION_ID =:APP_IDGreetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • Using jsp creating the xml file on the browser

    Hi All,
    My problem is i have jsp page by which i am getting the data from data base, by using the database table i want to create the xml file
    can anybody help in this issue

    Oh, "the thing". Let me see if I can find that code for you ...

  • Using informations about the XML Data Set in *.js

    Dear Users,
    I hope I am able to explane my problem correctly:
    I wonna create a fade effect with various pictures. They don't should blend to 0 - I found a js script that lets the pictures fade from one to the other like this: www.sv-guenther.de
    What this script needs is the number of pictures. I put the picture links into an XML file. Everything works as long as write the number or length of the picture children manually.
    I tried to read out the length by using the ds_RowCount option. This works fine as long as I use this in HTML context like this:
    <div spry:region="ds1" ><script type="text/javascript">  alert({ds_RowCount});</script>{ds_RowCount}</div>
    Both works: The alert shows the number 21 AND you can read the "21" and not {ds_RowCount}.
    okay, but how do I use the "21" integer in a script block in the head area? like this:
    <head>
    <script type="text/javascript">
    var x = {ds_RowCount};
    </script>
    </head>
    I tried it in different ways: var x = '{ds_RowCount}'; or spry:....
    As you can see: I am afraid my scripting knowledge is not the best - like my English is...
    Sorry and thank you very much for your help! - any kind of help
    best regards from Bonn, Germany
    Thorsten

    Dear Ben,
    if you would see me, you wouldn't laugh anymore, you would cry -) - but you are in DownUnder - this would look like I am laughing for you - wouldn't it?
    Thank yoou so much for remembering me. I have been reading your post about this topic (blend a picture). Once somebody asked the same (or almost the same) like I did yesterday. But the difference is, that if you blend a text to 0 it is big diference blending a picture - in my mind. I would love to reduce the opacity from one picture when the next picture is already behind it. So it looks like a smooth fade in fade out, without displaying the background.
    I found a quite good code example for this:HERE
    To make it as easy as possible for me I tried to include the number of the pictures straight into the js code. in the meantime I found the correct code option for this: What I was looking for was: getData() and if I combine it with an observer to wait for the "onPostLoad" everything works fine. I am ashamed that I asked first and then lokked into the SPRY API - Sorry!
    Everything works fine? No not yet - unfourtunally. So I am pleased to get the chance to ask a second time:
    Let's say I have more than one picture and more than one topic. So my XML looks like this:
    <leistungen>
    <inhalte name="Bauvorhaben">
         <inhalt name="Bautechnische Beratung">
         <texte>
              <text>Beurteilung der Baubeschreibung, Beratung zur Ausführungsplanung</text>
         </texte>
         <bilder>
              <bild></bild>
         </bilder>
         </inhalt>
         <inhalt name="Baubegleitende Qualitätsüberwachung">
         <texte>
              <text>Stichprobenhafte Kontrollen der Bauausführung zur Gewährleistung der Einhaltung anerkannter Regeln der Bautechnik und vertraglicher Vereinbarungen</text>
         </texte>
         <bilder>
              <bild>3867</bild>
         </bilder>
         </inhalt>
         <inhalt name="Baumängel">
         <texte>
              <text>Feststellung und Beurteilung von Baumängeln, Ursachenermittlung,Sanierungsempfehlung, Schätzung der Instandsetzungskosten</text>
         </texte>
         <bilder>
              <bild>2857</bild>
              <bild>3612</bild>
         </bilder>
         </inhalt>
         <inhalt name="Beweissicherung">
         <texte>
              <text>Dokumentation von  Schäden an  Bestandsgebäuden im Einflußbereich von Bauvorhaben, Beurteilung von Schadensansprüchen</text>
              <text>Bauzustandsdokumentation, Leistungsfeststellung</text>
         </texte>
         <bilder>
              <bild>1176</bild>
              <bild>154</bild>
         </bilder>
         </inhalt>
         <inhalt name="Abnahme von Bauleistungen / Abnahmebegleitung">
         <texte>
              <text>Einfamilienhäuser</text>
              <text>Mehrfamilienhäuser</text>
              <text>Wohnanlagen</text>
              <text>Bürogebäude</text>
         </texte>
         <bilder>
              <bild>2485</bild>
              <bild>3485</bild>
              <bild>3481</bild>
              <bild>3460</bild>
         </bilder>
         </inhalt>
         <inhalt name="Schiedsgutachten">
         <texte>
              <text>Rechtsverbindliche Beurteilung von Bauprozessen und Gewerken zur Konfliktvermeidung und -lösung</text>
         </texte>
         <bilder>
              <bild>7080</bild>
         </bilder>
         </inhalt>
    </inhalte>
    <inhalte name="Bestandsgebäude">
         <inhalt name="Beweissicherung">
         <texte>
              <text>Dokumentation von  Schäden an  Bestandsgebäuden im Einflußbereich von Neubauten, Beurteilung von Schadensansprüchen</text>          
         </texte>
         <bilder>
              <bild>1176</bild>          
         </bilder>
         </inhalt>
         <inhalt name="Gebäudeschäden">
         <texte>
              <text>Feststellung und Beurteilung von Gebäudeschäden, Ursachenermittlung, Sanierungsempfehlung, Kostenschätzung</text>
              <text>Bautechnische Beratung beim Kauf einer Bestandsimmobilie</text>
         </texte>
         <bilder>
              <bild>2108</bild>
              <bild>4004</bild>
              <bild>1387</bild>
              <bild>3488</bild>
         </bilder>
         </inhalt>
    </inhalte>
    </leistungen>
    First I create an new object
    var ds1 = new Spry.Data.XMLDataSet("xml/leistungen.xml", "leistungen/inhalte/inhalt/texte");
    So the  dsR =  ds1.getData() gives me a dsR.length = 8 - correct - because this XML has got 8 <texte> nodes. But some of these <texte> nodes have more than one <text> node. If I asked for the contet of the fifth node dsR[4]["text"] it gives me back "Bürogebäude" = the last sub node content. I wished I could catch the first, second, third as well. Just like a spry:repeat - do you understand?
    I figured out that it doesn't help to extend the string like
    dsR[4][0]["text"] or dsR[4][0][0].
    As far as I understood the Spry framework flattens the XML like a table. So I thought that there might be just in this raw, in the actual column just another object (not a string)  to be found.This object  I could touch or open with square brackets. Like
    dsR[0]["texte"][0]
    - but: I can't!
    But this would mean, that straight in js I could always only catch the first node value??? I must be wrong!!!  But I don't know were!
    Dear Ben, Dear Guys out there - is this to difficult what I am looking for or am I blind?
    thank you so much for helping me out here - again!

  • Using XLST  in the XML output returned.

    I have written a SQL (using 10G) which creates an XML document using the XML syntax and the output
    is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <FIXML xmlns="http://www.fixprotocol.org/FIXML-4-4"><Order Acct="1" Px="480.25"
    SettlDt="2009-12-01" SettlTyp="0" Side="1" StopPx="480.25" Typ="2">
    <TrdSes SesID="0"/><Instrmt CpnRt="5.1" EncIssrLen="2" ID="3134865" Issr="Barclays"
    MMY="200903" Mult="1.0" OptAt="L" SecTyp="BA" Sfx="P" Src="2" />
    </Order></FIXML>I need to use XSLT to convert the above XML in the format attached below.
    - <i:Interest >
      <i:OrderAct>1</i:OrderAct>
      <i:StopPx>480.25</i:StopPx>
      <i:Issr>Barclays</i:Issr>
      <i:Ref />
      </i:Interest>i know that this is not the forum to ask XSLT,but as I am using 10G with SQL,can anyone
    just send in a small XSLT script which I can use as a template and create XSLT.
    This is the first time I am using XSLT.
    Again,no offence meant if this is not the correct forum but help really appreciated.
    Thanks,

    What's wrong with Sundars answer in this Writing a Procedure to return back XML. Please help.?

  • Using XPath with the XML DOM

    I have just started to use the XML DOM API. One thing I cannot see yet is an easy way to use XPath to get the value of an element.
    What I would like to do is pass an XPath expression like this:
    \EDIFACT\ORDERS\NAD[2]\NAD01\NAD0102
    into a method, and get the value of the element returned to me.
    Does anybody know if there is a method of one of the DOM interfaces that would provide that kind of functionality, or am I going to have to traverse the nodes of the DOM tree manually to do this?
    BR,
    Tony.

    Hi Tony,
    I read your posted question - I have the same problem.
    I think that the method find_from_path_ns (or find_from_path) is the only "xpath"-like way to get a value.
    BUT the syntax is very limited so you cannot use all good features of xpath
    To traverse the nodes manually is (in my problem) unpractible - the xml-structures are different and it's horrible to traverse the tree.
    I need xpaths like ' //x/y[3]/z[a='MS']' . I know, the performance is not very good but for small XML-messages fast enough
    Do you have any solutions?
    regards
    Wolfgang Hummel

  • What is the best way to change a namespace in an xml document

    Hi,
    I need to change an xml namespaces. The xml has about 200 elements and every element may have a namespace attribute (namespaces are all the same).
    Is there any better solution then the following function?
    SQL> create or replace function change_namespace(p_xml xmltype, p_namespace varchar2) return xmltype is
      2    l_doc dbms_xmldom.DOMDocument;
      3    l_nodes dbms_xmldom.DOMNodelist;
      4    l_node dbms_xmldom.DOMNode;
      5  begin
      6    l_doc:=dbms_xmldom.NewDOMDocument(p_xml);
      7    l_nodes:=dbms_xmldom.getElementsByTagName(l_doc,'*');
      8    for i in 0..dbms_xmldom.getlength(l_nodes)-1 loop
      9      l_node:=dbms_xmldom.item(l_nodes,i);
    10      if i=0 then
    11        --set namespace only for the root node
    12        dbms_xmldom.setattribute(dbms_xmldom.makeElement(l_node),'xmlns',p_namespace);
    13      else
    14        --remove all the other namespaces
    15        dbms_xmldom.removeattribute(dbms_xmldom.makeElement(l_node),'xmlns');
    16      end if;
    17    end loop;
    18 
    19    return dbms_xmldom.getxmltype(l_doc);
    20  end;
    21  /
    Function created.
    SQL> select change_namespace(xmltype('<a xmlns="aaa"><b xmlns="aaa">4</b><c>44</c></a>'),'newnamespace')
      2  from dual;
    CHANGE_NAMESPACE(XMLTYPE('<AXMLNS="AAA"><BXMLNS="AAA">4</B><C>44</C></A>'),'NEWN
    <a xmlns="newnamespace">                                                       
      <b>4</b>                                                                     
      <c>44</c>                                                                    
    </a> Ants

    Hi,
    I found a better and almost 10x faster way to remove the namespaces, using xsl.
    here's the original xsl with a little modifications http://bytes.com/forum/thread448445.html
    SQL> with t as (select xmltype('<a xmlns="aaa"><b xmlns="aaa">4</b><c>44</c></a>') xcol from dual)
      2  select xmltransform(xcol
      3    ,xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
      4               <xsl:template match="*">
      5                <xsl:element name="{local-name()}" namespace="">
      6                 <xsl:apply-templates select="@* | node()" />
      7                </xsl:element>
      8               </xsl:template>
      9              </xsl:stylesheet>'))
    10  from t;
    XMLTRANSFORM(XCOL,XMLTYPE('<XSL:STYLESHEETVERSION="1.0"XMLNS:XSL="HTTP://WWW.W3.
    <a><b>4</b><c>44</c></a>+but check Laurents Schneider's blog website+
    I didn't find any posts about namespace on Schneider's blog.
    Ants

  • Use of Global Properties in URL path of XML Query

    I am trying to use global properties to define the URL of XML query:
    Globals.ImageFilePath&"SomePath/\File.xml"
    but it does not like it. If I put the content of the Globals.ImageFilePath it works fine. What is the synatax for that?
    I am using the XML query in a transaction within an image creation action block. When I try to define the URL parameter of the XML file as a link, it is not taken on account, and the image created has no data (it is empty). The URL is taken when defined on the Cofigure Object screen, but there I have the same problem to use the global variable parameter.
    Any suggestions?
    Thanks,
    Vlad
    Edited by: Vladimir Baltchev on Jul 29, 2008 11:33 PM
    Edited by: Vladimir Baltchev on Jul 29, 2008 11:40 PM

    As I mentioned in my first posting, yes, I can put the global variable of the link editor for the URL parameter, it evaluates well, but it is not taken on account by the query, and the image generated is empty. Obviously there is a bug here, so I am trying to find a work around to use the global variable on the Configure Object screen, where the parameter URL is taken by the XML query, but on this screen I can not use the global variable. It works only if I put the content of the global variable.
    So, does anybody know if we can use global variables on a Configure Object  screen, or on the XML query URL field, and if so, what is the syntax to indicate global variable?
    Thanks again,
    Vlad

  • Using API to download the webi document in the XML format

    I am just trying to use this API to download the webi document in the XML format. I need a sample XSL file which we can use to download the XML in a formatted output.
    http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/en/RE_SDK/resdk_java_doc/doc/resdk_java_apiRef/com/businessobjects/rebean/wi/XMLView.html
    getReader
    public java.io.Reader getReader(java.net.URL xsl)
                             throws REException
    Return the result of the XSL transformation applied to the XML report output stream.
    Parameters:
    xsl - URL to an XSL file used to transform report XML.
    Since:
    11.5
    See Also:
    getReader()

    If the same content of file already thr in the Internal table as 1 STRING/LINE then you can loop the internal table count the entries which one you want like
    Kanagaraja L

  • Cooresponding Lists Names/Values XML Query

    Let's say there is an XML Schema that has
    <element name="mt" minOccurs="0" maxOccurs="unbounded">
    <element name="r" minOccurs="0" maxOccurs="unbounded">
    And for each measurement type (mt), you have a cooresponding measurement value (r). There are additional elements between these two lists. The actual XML data would look similiar to
    <mi>
         <mts>20061117100000-0800</mts>
         <gp>900</gp>
         <mt>MeasurementType1</mt>
         <mt>MeasurementType2</mt>
         <mt>MeasurementType3</mt>
         <mt>MeasurementType4</mt>
         <mt>MeasurementType5</mt>
         <mt>MeasurementType6</mt>
         <mt>MeasurementType7</mt>
         <mv>
              <moid>Identifier</moid>
              <r>58</r>
              <r>62</r>
              <r>43</r>
              <r>45</r>
              <r>43</r>
              <r>14</r>
              <r>29</r>
              <sf>FALSE</sf>
         </mv>
    </mi>
    The first occurance of mt corresponds to the first occurance of r, the second cooresponds to the second, et cetra.
    The MI element can repeat hundreds of times and there can be many measurementTypes. Now, I'm trying to figure out how I can create an XML query to efficiently handle this. The problem is that the <r> value is within the complexType <mv> and that is on the same level as <mt>. The XML Query would cause a cartesian product if I were to use something like ...
    select
    extractValue(value(xmldata), '/mi/mts') measurement_time_stamp,
    extractValue(value(xmldata), '/mi/gp') granularity_period,
    extractValue(value(mt), '/mt') measurement_type,
    extractValue(value(mv), '/mv/moid') measured_obj_id,
    extractValue(value(r), '/r') measurement_value,
    from xmltable
    , TABLE(XMLSequence(Extract(value(xmltable), '/mi/mv'))) mv
    , TABLE(XMLSequence(Extract(value(mi), '/mi/mt'))) mt
    , TABLE(XMLSequence(Extract(value(mi), '/mv/r'))) r
    This obviously wouldn't work. I could go and store all the types and values into a column using
    select
    replace(replace(replace(extract(value(mi), '/mi/mt').getStringVal(), '</mt><mt>', ';'), '<mt>'), '</mt>') measurement_type,
    extractValue(value(mv), '/mv/moid') measured_obj_id,
    replace(replace(replace(extract(value(mv), '/mv/r').getStringVal(), '</r><r>', ';'), '<r>'), '</r>') measurement_value
    from xmltable
    TABLE(XMLSequence(Extract(value(xmldata), '/md/mi'))) mi
    , TABLE(XMLSequence(Extract(value(mi), '/mi/mv'))) mv
    But this wouldn't work once the XML grew over 4000 bytes. So I need a way to extract this data maintaining the correct integrity (avoiding cartesians).
    One idea is a pipelined table function but I have concerns about scalability with that method. Is there a way to accomplish this optimally? I have solutions for this but none of them is going to deliver the scalability I am seeking.
    I expect the method chosen will probably need to handle a few hundred thousand files per day.
    Thanks,

    VJ
    I'd not seen your XML schema when I worked the original example, so I reverse engineered it from the instance. Unfortunately when I work with your schema, which contains more levels of nested I can't get it to optimize properly
    Here's what should work in theory
    SQL> set echo on
    SQL> spool testcase.log
    SQL> --
    SQL> connect sys/ as sysdba
    Enter password:
    Connected.
    SQL> set define on
    SQL> --
    SQL> define USERNAME = OTNTEST
    SQL> --
    SQL> def PASSWORD = OTNTEST
    SQL> --
    SQL> def USER_TABLESPACE = USERS
    SQL> --
    SQL> def TEMP_TABLESPACE = TEMP
    SQL> --
    SQL> def LOCAL_FILESYSTEM = 'C:\xdb\otn\457595'
    SQL> --
    SQL> drop user &USERNAME cascade
      2  /
    old   1: drop user &USERNAME cascade
    new   1: drop user OTNTEST cascade
    User dropped.
    SQL> grant connect, resource to &USERNAME identified by &PASSWORD
      2  /
    old   1: grant connect, resource to &USERNAME identified by &PASSWORD
    new   1: grant connect, resource to OTNTEST identified by OTNTEST
    Grant succeeded.
    SQL> grant create any directory, drop any directory to &USERNAME
      2  /
    old   1: grant create any directory, drop any directory to &USERNAME
    new   1: grant create any directory, drop any directory to OTNTEST
    Grant succeeded.
    SQL> grant alter session, create view to &USERNAME
      2  /
    old   1: grant alter session, create view to &USERNAME
    new   1: grant alter session, create view to OTNTEST
    Grant succeeded.
    SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
      2  /
    old   1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
    new   1: alter user OTNTEST default tablespace USERS temporary tablespace TEMP
    User altered.
    SQL> connect &USERNAME/&PASSWORD
    Connected.
    SQL> --
    SQL> alter session set events ='19027 trace name context forever, level 0x800'
      2  /
    Session altered.
    SQL> var schemaURL varchar2(256)
    SQL> var schemaPath varchar2(256)
    SQL> --
    SQL> create or replace directory XMLDIR as '&LOCAL_FILESYSTEM'
      2  /
    old   1: create or replace directory XMLDIR as '&LOCAL_FILESYSTEM'
    new   1: create or replace directory XMLDIR as 'C:\xdb\otn\457595'
    Directory created.
    SQL> begin
      2    :schemaURL := 'testcase.xsd';
      3    :schemaPath := '/public/testcase.xsd';
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> declare
      2    res boolean;
      3    xmlSchema xmlType := xmlType(
      4  '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
      5  <!--W3C Schema generated by XMLSpy v2007 (http://www.altova.com)-->
      6  <!--Please add namespace attributes, a targetNamespace attribute and import elements according to your requirements-->
      7  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" attributeFormDefaul
    t="unqualified" xdb:storeVarrayAsTable="true">
      8     <xs:import namespace="http://www.w3.org/XML/1998/namespace"/>
      9     <xs:element name="mdc" xdb:defaultTable="MDC_TABLE">
    10             <xs:complexType xdb:SQLType="MDC_TYPE" xdb:maintainDOM="false">
    11                     <xs:sequence>
    12                             <xs:element ref="mfh"/>
    13                             <xs:element ref="md" minOccurs="0" maxOccurs="unbounded"/>
    14                             <xs:element ref="mff"/>
    15                     </xs:sequence>
    16             </xs:complexType>
    17     </xs:element>
    18     <xs:element name="mfh" xdb:defaultTable="">
    19             <xs:complexType xdb:SQLType="MFH_TYPE" xdb:maintainDOM="false">
    20                     <xs:sequence>
    21                             <xs:element ref="ffv"/>
    22                             <xs:element ref="sn"/>
    23                             <xs:element ref="st"/>
    24                             <xs:element ref="vn"/>
    25                             <xs:element ref="cbt"/>
    26                     </xs:sequence>
    27             </xs:complexType>
    28     </xs:element>
    29     <xs:element name="md" xdb:defaultTable="" >
    30             <xs:complexType  xdb:SQLType="MD_TYPE" xdb:maintainDOM="false">
    31                     <xs:sequence>
    32                             <xs:element ref="neid"/>
    33                             <xs:element ref="mi" minOccurs="0" maxOccurs="unbounded" />
    34                     </xs:sequence>
    35             </xs:complexType>
    36     </xs:element>
    37     <xs:element name="neid" xdb:defaultTable="" >
    38             <xs:complexType xdb:SQLType="NEID_TYPE" xdb:maintainDOM="false">
    39                     <xs:sequence>
    40                             <xs:element ref="neun"/>
    41                             <xs:element ref="nedn"/>
    42                     </xs:sequence>
    43             </xs:complexType>
    44     </xs:element>
    45     <xs:element name="mi" xdb:defaultTable="" >
    46             <xs:complexType xdb:SQLType="MI_TYPE" xdb:maintainDOM="false">
    47                     <xs:sequence>
    48                             <xs:element ref="mts"/>
    49                             <xs:element ref="gp"/>
    50                             <xs:element ref="mt" minOccurs="0" maxOccurs="unbounded"/>
    51                             <xs:element ref="mv" minOccurs="0" maxOccurs="unbounded" />
    52                     </xs:sequence>
    53             </xs:complexType>
    54     </xs:element>
    55     <xs:element name="mv" xdb:defaultTable="" >
    56             <xs:complexType xdb:SQLType="MV_TYPE" xdb:maintainDOM="false">
    57                     <xs:sequence>
    58                             <xs:element ref="moid"/>
    59                             <xs:element ref="r" minOccurs="0" maxOccurs="unbounded"/>
    60                             <xs:element ref="sf" minOccurs="0"/>
    61                     </xs:sequence>
    62             </xs:complexType>
    63     </xs:element>
    64     <xs:element name="mff" xdb:defaultTable="" >
    65             <xs:complexType xdb:maintainDOM="false">
    66                     <xs:sequence>
    67                             <xs:element ref="ts"/>
    68                     </xs:sequence>
    69             </xs:complexType>
    70     </xs:element>
    71     <xs:element name="ts" type="xs:string"/>
    72     <xs:element name="sf" type="xs:string"/>
    73     <xs:element name="r">
    74             <xs:complexType xdb:SQLType="R_TYTPE" xdb:maintainDOM="false">
    75                     <xs:simpleContent>
    76                             <xs:extension base="xs:string">
    77                                     <xs:attribute ref="dummy" use="prohibited"/>
    78                             </xs:extension>
    79                     </xs:simpleContent>
    80             </xs:complexType>
    81     </xs:element>
    82     <xs:attribute name="dummy" type="xs:boolean"/>
    83     <xs:element name="mt">
    84             <xs:complexType xdb:SQLType="MT_TYTPE" xdb:maintainDOM="false">
    85                     <xs:simpleContent>
    86                             <xs:extension base="xs:string">
    87                                     <xs:attribute ref="dummy" use="prohibited"/>
    88                             </xs:extension>
    89                     </xs:simpleContent>
    90             </xs:complexType>
    91     </xs:element>
    92     <xs:element name="moid" type="xs:string"/>
    93     <xs:element name="gp" type="xs:string"/>
    94     <xs:element name="mts" type="xs:string"/>
    95     <xs:element name="nedn" type="xs:string"/>
    96     <xs:element name="neun" type="xs:string"/>
    97     <xs:element name="cbt" type="xs:string"/>
    98     <xs:element name="vn" type="xs:string"/>
    99     <xs:element name="st" type="xs:string"/>
    100     <xs:element name="sn" type="xs:string"/>
    101     <xs:element name="ffv" type="xs:string"/>
    102  </xs:schema>');
    103  begin
    104    if (dbms_xdb.existsResource(:schemaPath)) then
    105      dbms_xdb.deleteResource(:schemaPath);
    106    end if;
    107    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    108  end;
    109  /
    PL/SQL procedure successfully completed.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      :schemaURL,
      5      xdbURIType(:schemaPath).getClob(),
      6      TRUE,TRUE,FALSE,TRUE
      7    );
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> declare
      2    nested_table_name varchar2(256);
      3    iot_index_name varchar2(256);
      4  begin
      5    select table_name
      6      into nested_table_name
      7      from user_nested_tables
      8     where parent_table_column = '"XMLDATA"."md"'
      9       and parent_table_name = 'MDC_TABLE';
    10
    11    execute immediate 'rename "'|| nested_table_name ||'" to MD_TABLE';
    12
    13    select index_name
    14      into iot_index_name
    15      from user_indexes
    16     where table_name = 'MD_TABLE' and index_type = 'IOT - TOP';
    17
    18    execute immediate 'alter index "'|| iot_index_name ||'" rename to MD_IOT';
    19
    20    select table_name
    21      into nested_table_name
    22      from user_nested_tables
    23     where parent_table_column = 'mi'
    24       and parent_table_name = 'MD_TABLE';
    25
    26    execute immediate 'rename "'|| nested_table_name ||'" to MI_TABLE';
    27
    28    select index_name
    29      into iot_index_name
    30      from user_indexes
    31     where table_name = 'MI_TABLE' and index_type = 'IOT - TOP';
    32
    33    execute immediate 'alter index "'|| iot_index_name ||'" rename to MI_IOT';
    34
    35    select table_name
    36      into nested_table_name
    37      from user_nested_tables
    38     where parent_table_column = 'mt'
    39       and parent_table_name = 'MI_TABLE';
    40
    41    execute immediate 'rename "'|| nested_table_name ||'" to MT_TABLE';
    42
    43    select index_name
    44      into iot_index_name
    45      from user_indexes
    46     where table_name = 'MT_TABLE' and index_type = 'IOT - TOP';
    47
    48    execute immediate 'alter index "'|| iot_index_name ||'" rename to MT_IOT';
    49
    50    select table_name
    51      into nested_table_name
    52      from user_nested_tables
    53     where parent_table_column = 'mv'
    54       and parent_table_name = 'MI_TABLE';
    55
    56    execute immediate 'rename "'|| nested_table_name ||'" to MV_TABLE';
    57
    58    select index_name
    59      into iot_index_name
    60      from user_indexes
    61     where table_name = 'MV_TABLE' and index_type = 'IOT - TOP';
    62
    63    execute immediate 'alter index "'|| iot_index_name ||'" rename to MV_IOT';
    64
    65    select table_name
    66      into nested_table_name
    67      from user_nested_tables
    68     where parent_table_column = 'r'
    69       and parent_table_name = 'MV_TABLE';
    70
    71    execute immediate 'rename "'|| nested_table_name ||'" to R_TABLE';
    72
    73    select index_name
    74      into iot_index_name
    75      from user_indexes
    76     where table_name = 'R_TABLE' and index_type = 'IOT - TOP';
    77
    78    execute immediate 'alter index "'|| iot_index_name ||'" rename to R_IOT';
    79  end;
    80  /
    PL/SQL procedure successfully completed.
    SQL> desc MDC_TABLE
    Name                                                                                Null?    Type
    TABLE of SYS.XMLTYPE(XMLSchema "testcase.xsd" Element "mdc") STORAGE Object-relational TYPE "MDC_TYPE"
    SQL> --
    SQL> desc MD_TABLE
    Name                                                                                Null?    Type
    neid                                                                                         NEID_TYPE
    mi                                                                                           mi9495_COLL
    SQL> --
    SQL> desc MI_TABLE
    Name                                                                                Null?    Type
    mts                                                                                          VARCHAR2(4000 CHAR)
    gp                                                                                           VARCHAR2(4000 CHAR)
    mt                                                                                           mt9493_COLL
    mv                                                                                           mv9494_COLL
    SQL> --
    SQL> desc MT_TABLE
    Name                                                                                Null?    Type
    SYS_XDBBODY$                                                                                 VARCHAR2(4000 CHAR)
    dummy                                                                                        RAW(1)
    SQL> --
    SQL> desc MV_TABLE
    Name                                                                                Null?    Type
    moid                                                                                         VARCHAR2(4000 CHAR)
    r                                                                                            r9492_COLL
    sf                                                                                           VARCHAR2(4000 CHAR)
    SQL> --
    SQL> desc R_TABLE
    Name                                                                                Null?    Type
    SYS_XDBBODY$                                                                                 VARCHAR2(4000 CHAR)
    dummy                                                                                        RAW(1)
    SQL> --
    SQL> set autotrace on explain
    SQL> set lines 150 pages 100
    SQL> --
    SQL> var XMLTEXT varchar2(4000)
    SQL> --
    SQL> begin
      2    :xmlText :=
      3  '<mdc>
      4     <mfh>
      5             <ffv/>
      6             <sn/>
      7             <st/>
      8             <vn/>
      9             <cbt/>
    10     </mfh>
    11     <md>
    12             <neid>
    13                     <neun/>
    14                     <nedn/>
    15             </neid>
    16             <mi>
    17                     <mts>20061117100000-0800</mts>
    18                     <gp>900</gp>
    19                     <mt>MeasurementType1</mt>
    20                     <mt>MeasurementType2</mt>
    21                     <mt>MeasurementType3</mt>
    22                     <mt>MeasurementType4</mt>
    23                     <mt>MeasurementType5</mt>
    24                     <mt>MeasurementType6</mt>
    25                     <mt>MeasurementType7</mt>
    26                     <mv>
    27                             <moid>Identifier</moid>
    28                             <r>58</r>
    29                             <r>62</r>
    30                             <r>43</r>
    31                             <r>45</r>
    32                             <r>43</r>
    33                             <r>14</r>
    34                             <r>29</r>
    35                             <sf>FALSE</sf>
    36                     </mv>
    37             </mi>
    38     </md>
    39     <mff>
    40             <ts/>
    41     </mff>
    42  </mdc>';
    43  end;
    44  /
    PL/SQL procedure successfully completed.
    SQL> insert into MDC_TABLE values ( xmltype ( :xmltext ))
      2  /
    1 row created.
    Execution Plan
    Plan hash value: 1621636734
    | Id  | Operation                | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | INSERT STATEMENT         |           |     1 |   100 |     1   (0)| 00:00:01 |
    |   1 |  LOAD TABLE CONVENTIONAL | MDC_TABLE |       |       |            |          |
    SQL> commit
      2  /
    Commit complete.
    SQL> select MT_INDEX, MT_VALUE, R_VALUE
      2    from MDC_TABLE,
      3         xmlTable
      4         (
      5           '/mdc/md/mi'
      6           passing object_value
      7           columns
      8           XML xmltype path '.'
      9         ) MI,
    10         xmlTable
    11         (
    12           '/mi/mt'
    13           passing MI.XML
    14           columns
    15           MT_INDEX for ordinality,
    16           MT_VALUE varchar2(32) path 'text()'
    17         ) MT,
    18         xmlTable
    19         (
    20           '/mi/mv/r'
    21           passing MI.XML
    22           columns
    23           R_INDEX for ordinality,
    24           R_VALUE varchar2(32) path 'text()'
    25         ) R
    26   where MT_INDEX = R_INDEX
    27  /
      MT_INDEX MT_VALUE                         R_VALUE
             1 MeasurementType1                 58
             2 MeasurementType2                 62
             3 MeasurementType3                 43
             4 MeasurementType4                 45
             5 MeasurementType5                 43
             6 MeasurementType6                 14
             7 MeasurementType7                 29
    7 rows selected.
    Execution Plan
    Plan hash value: 2832518671
    | Id  | Operation                             | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                      |                        |  5449M|    19T|  1616M  (1)|999:59:59 |
    |   1 |  NESTED LOOPS                         |                        |  5449M|    19T|  1616M  (1)|999:59:59 |
    |   2 |   NESTED LOOPS                        |                        |    66M|   237G|   197K  (1)| 00:39:36 |
    |   3 |    NESTED LOOPS                       |                        |  8168 |    29M|    27   (0)| 00:00:01 |
    |*  4 |     TABLE ACCESS FULL                 | MDC_TABLE              |     1 |  3788 |     3   (0)| 00:00:01 |
    |   5 |     COLLECTION ITERATOR PICKLER FETCH | XMLSEQUENCEFROMXMLTYPE |       |       |            |          |
    |   6 |    VIEW                               |                        |  8168 |   247K|    24   (0)| 00:00:01 |
    |   7 |     COUNT                             |                        |       |       |            |          |
    |   8 |      COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE |       |       |            |          |
    |*  9 |   VIEW                                |                        |    82 |  2542 |    24   (0)| 00:00:01 |
    |  10 |    COUNT                              |                        |       |       |            |          |
    |  11 |     COLLECTION ITERATOR PICKLER FETCH | XMLSEQUENCEFROMXMLTYPE |       |       |            |          |
    Predicate Information (identified by operation id):
       4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
                  xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd
                  DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-properties/><read-contents/></privilege>'))=1)
       9 - filter("MT_INDEX"="R_INDEX")
    Note
       - dynamic sampling used for this statement
    SQL>As you can see the re-write is not working out in this case. I'll ask development to take a look at it and see if they can solve it. I think it's similar to another bug I've filed...
    WRT to your question about transforming. One easy transformation would be to number the nodes.. Eg use XSTL to add an index number to each MT node and each R node and then join on that value.

Maybe you are looking for

  • Edit field in alv

    Hi I look how to make column editable in alv with class CL_SALV_TABLE thanks have a nice day

  • Getting error while accessing a webpage by using link local address of ipv6

    Hello, I want to access my login.jsp by using ipv6 address. when i am accessing my web page by using loop back or localhost6(like the following) it is working. http://[::1]:8080/test/login.jsp //for loopback http://localhost6:8080/test/login.jsp But

  • Field Separator

    The Flat file(.txt) has 5 fields separated by vertical bars(|). this fils has to be uploaded using the FM 'UPLOAD'.      Here the problem is, the internal table is not taking the individual field values, but it is taking the values of 2 or 3 fields i

  • Ghost Books on iBooks

    I purchased some books from itunes on my pc. When it came to syncing my iphone with itunes it will display a front cover of these books (with the download progress bar on empty), but i can neither redeem the books, nor delete them. If i search for th

  • SONY is a quality brand.

    SONY XPERIA series is advertising for the brand .SONY is a quality brand .Few xperia should be made .3 models to be produced.Low,medium and high segments.Example SEGMENTS ; XPERIA E(aluminum case and plastic cover), M(aliminum case and glass cover) a