From XML in CLOB to relational table doubt

versions 11.2.0.2.0 / 10.2.0.4.0
It's a long time, no see since my last dealing with xml and no luck to have an attribute value returned into the relational table.
It's *<IntrBkSttlmAmt Ccy="???">999999</IntrBkSttlmAmt>*
For the rest the below works in both versions but used on an xml having a 10000 <CdtTrfTxInf> on 11g it took 9 seconds and was killed because no answer was produced after 30 minutes on 10g. A colleague using java loaded the relational table in 34 seconds on 10g and produced the relational table on 11g in just 5 seconds.
The 10g version is surviving with no xmldb installed and there are rumors our thinking heads didn't succeed to deactivate it on 11g yet.
Any suggestion concerning alternate ways to produce a relational table from an xmltype located in a clob column of a relational table are welcome
(looking at CLOB in XML to Normal table Best approach? I thought too many xmltable would have to be used)
with
the_data as
(select q'~
            <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.01">
               <pacs.008.001.01>
                  <GrpHdr>
                     <MsgId>1L1U000JB4UT1FVS</MsgId>
                     <MsgId>9X9X999XX9XX9XXX</MsgId>
                     <CreDtTm>YYYY-MM-DDTHH:MI:SS</CreDtTm>
                     <NbOfTxs>99999</NbOfTxs>
                     <TtlIntrBkSttlmAmt Ccy="???">9999999</TtlIntrBkSttlmAmt>
                     <IntrBkSttlmDt>YYYY-MM-DD</IntrBkSttlmDt>
                        <SttlmInf>
                           <SttlmMtd>XXXX</SttlmMtd>
                              <ClrSys>
                                  <ClrSysId>XXXX</ClrSysId>
                              </ClrSys>
                           </SttlmInf>
                  </GrpHdr>
                  <CdtTrfTxInf>
                     <PmtId>
                        <InstrId>XXXXXXX999999-XX999999.XX</InstrId>
                        <EndToEndId>X9999999999</EndToEndId>
                        <TxId>X9999-9999999999</TxId>
                     </PmtId>
                     <PmtTpInf>
                        <SvcLvl>
                           <Cd>XXXX</Cd>
                        </SvcLvl>
                    </PmtTpInf>
                    <IntrBkSttlmAmt Ccy="???">999999</IntrBkSttlmAmt>
                    <ChrgBr>XXXX</ChrgBr>
                    <InstgAgt>
                       <FinInstnId>
                          <BIC>XXXXXX9X</BIC>
                       </FinInstnId>
                    </InstgAgt>
                    <Dbtr>
                       <Nm>NAME</Nm>
                       <PstlAdr>
                          <AdrLine>ADDRESS</AdrLine>
                          <AdrLine>CITY</AdrLine>
                          <Ctry>XX</Ctry>
                       </PstlAdr>
                    </Dbtr>
                    <DbtrAcct>
                       <Id>
                          <IBAN>XX99999999999999999</IBAN>
                       </Id>
                    </DbtrAcct>
                    <DbtrAgt>
                       <FinInstnId>
                          <BIC>XXXXXX9X</BIC>
                       </FinInstnId>
                    </DbtrAgt>
                    <CdtrAgt>
                       <FinInstnId>
                          <BIC>XXXXXX9X</BIC>
                       </FinInstnId>
                    </CdtrAgt>
                    <Cdtr>
                       <Nm>NAME</Nm>
                       <PstlAdr>
                          <AdrLine>ADDRESS</AdrLine>
                          <AdrLine>CITY</AdrLine>
                          <Ctry>XX</Ctry>
                       </PstlAdr>
                    </Cdtr>
                    <CdtrAcct>
                       <Id>
                          <IBAN>XX99999999999999999</IBAN>
                       </Id>
                    </CdtrAcct>
                    <RmtInf>
                       <Strd>
                          <CdtrRefInf>
                             <CdtrRef>X99999999-9999999999</CdtrRef>
                          </CdtrRefInf>
                          <AddtlRmtInf>ADDITIONAL INFO</AddtlRmtInf>
                       </Strd>
                    </RmtInf>
                  </CdtTrfTxInf>
               </pacs.008.001.01>
            </Document>
          ~' the_column
   from dual
select v.instrid,v.endtoendid,v.txid,v.cd,
       v.ccy,  /* returned as NULL - the only attribute value */
       v.intrbksttlmamt,v.chrgbr,v.bic1,v.nm1,v.adrline11,v.adrline12,v.ctry1,v.iban1,
       v.bic2,v.bic3,v.nm2,v.adrline21,v.adrline22,v.ctry2,v.iban2,v.cdtrref,v.addtlrmtinf
  from (select xmltype(the_column) the_column_xml
          from the_data
       ) w,
       xmltable(xmlnamespaces(default 'urn:iso:std:iso:20022:tech:xsd:pacs.008.001.01'),
                'for $r in /Document/pacs.008.001.01/CdtTrfTxInf
                 return <rw>
                          <InstrId>{$r/PmtId/InstrId}</InstrId>
                          <EndToEndId>{$r/PmtId/EndToEndId}</EndToEndId>
                          <TxId>{$r/PmtId/TxId}</TxId>
                          <Cd>{$r/PmtTpInf/SvcLvl/Cd}</Cd>
                          <Ccy>{$r/IntrBkSttlmAmt/@Ccy}</Ccy>
                          <IntrBkSttlmAmt>{ora:replace($r/IntrBkSttlmAmt,"[.]",",")}</IntrBkSttlmAmt>
                          <ChrgBr>{$r/ChrgBr}</ChrgBr>
                          <BIC1>{$r/InstgAgt/FinInstnId}</BIC1>
                          <Nm1>{$r/Dbtr/Nm}</Nm1>
                          <AdrLine11>{$r/Dbtr/PstlAdr/AdrLine[1]}</AdrLine11>
                          <AdrLine12>{$r/Dbtr/PstlAdr/AdrLine[2]}</AdrLine12>
                          <Ctry1>{$r/Dbtr/PstlAdr/Ctry}</Ctry1>
                          <IBAN1>{$r/DbtrAcct/Id}</IBAN1>
                          <BIC2>{$r/DbtrAgt/FinInstnId}</BIC2>
                          <BIC3>{$r/CdtrAgt/FinInstnId}</BIC3>
                          <Nm2>{$r/Cdtr/Nm}</Nm2>
                          <AdrLine21>{$r/Cdtr/PstlAdr/AdrLine[1]}</AdrLine21>
                          <AdrLine22>{$r/Cdtr/PstlAdr/AdrLine[2]}</AdrLine22>
                          <Ctry2>{$r/Cdtr/PstlAdr/Ctry}</Ctry2>
                          <IBAN2>{$r/CdtrAcct/Id}</IBAN2>
                          <CdtrRef>{$r/RmtInf/Strd/CdtrRefInf/CdtrRef}</CdtrRef>
                          <AddtlRmtInf>{$r/RmtInf/Strd/AddtlRmtInf}</AddtlRmtInf>
                        </rw>'
                 passing w.the_column_xml
                 columns instrid         varchar2(300)   path '/rw/InstrId',
                         endtoendid      varchar2(150)   path '/rw/EndToEndId',
                         txid            varchar2(200)   path '/rw/TxId',
                         cd              varchar2(50)    path '/rw/Cd',
                         ccy             varchar2(50)    path '/rw/Ccy',
                         intrbksttlmamt  varchar2(50)    path '/rw/IntrBkSttlmAmt',
                         chrgbr          varchar2(100)   path '/rw/ChrgBr',
                         bic1            varchar2(100)   path '/rw/BIC1',
                         nm1             varchar2(1000)  path '/rw/Nm1',
                         adrline11       varchar2(1000)  path '/rw/AdrLine11',
                         adrline12       varchar2(1000)  path '/rw/AdrLine12',
                         ctry1           varchar2(50)    path '/rw/Ctry1',
                         iban1           varchar2(200)   path '/rw/IBAN1',
                         bic2            varchar2(100)   path '/rw/BIC2',
                         bic3            varchar2(100)   path '/rw/BIC3',
                         nm2             varchar2(1000)  path '/rw/Nm2',
                         adrline21       varchar2(1000)  path '/rw/AdrLine21',
                         adrline22       varchar2(1000)  path '/rw/AdrLine22',
                         ctry2           varchar2(50)    path '/rw/Ctry2',
                         iban2           varchar2(200)   path '/rw/IBAN2',
                         cdtrref         varchar2(1000)  path '/rw/CdtrRef',
                         addtlrmtinf     varchar2(1000)  path '/rw/AddtlRmtInf'
               ) vRegards
Etbin

Hi,
It's a long time, no see since my last dealing with xml and no luck to have an attribute value returned into the relational table.When you use this :
<Ccy>{$r/IntrBkSttlmAmt/@Ccy}</Ccy>That doesn't set the value of the Ccy element with the attribute value, but actually add the attribute Ccy to the element Ccy, which results in
<Ccy Ccy="???"></Ccy>Knowing that, you have three options :
1) Leaving the XQuery as it is and using this instead in the COLUMNS clause :
                         ccy             varchar2(50)    path '/rw/Ccy/@Ccy',2) Modifying the XQuery to get the atomic value out of the attribute (using the fn:data function) :
                          <Ccy>{fn:data($r/IntrBkSttlmAmt/@Ccy)}</Ccy>3) Simplifying the whole thing, something like :
select v.instrid, v.endtoendid, v.txid, v.cd, v.ccy,
       replace(v.intrbksttlmamt,'.',',') as intrbksttlmamt, v.chrgbr, v.bic1, v.nm1, v.adrline11, v.adrline12, v.ctry1, v.iban1,
       v.bic2, v.bic3, v.nm2, v.adrline21, v.adrline22, v.ctry2, v.iban2, v.cdtrref, v.addtlrmtinf
  from the_data w,
       xmltable(xmlnamespaces(default 'urn:iso:std:iso:20022:tech:xsd:pacs.008.001.01'),
                '/Document/pacs.008.001.01/CdtTrfTxInf'
                 passing xmltype(w.the_column)
                 columns instrid         varchar2(300)   path 'PmtId/InstrId',
                         endtoendid      varchar2(150)   path 'PmtId/EndToEndId',
                         txid            varchar2(200)   path 'PmtId/TxId',
                         cd              varchar2(50)    path 'PmtTpInf/SvcLvl/Cd',
                         ccy             varchar2(50)    path 'IntrBkSttlmAmt/@Ccy',
                         intrbksttlmamt  varchar2(50)    path 'IntrBkSttlmAmt',
                         chrgbr          varchar2(100)   path 'ChrgBr',
                         bic1            varchar2(100)   path 'InstgAgt/FinInstnId',
                         nm1             varchar2(1000)  path 'Dbtr/Nm',
                         adrline11       varchar2(1000)  path 'Dbtr/PstlAdr/AdrLine[1]',
                         adrline12       varchar2(1000)  path 'Dbtr/PstlAdr/AdrLine[2]',
                         ctry1           varchar2(50)    path 'Dbtr/PstlAdr/Ctry',
                         iban1           varchar2(200)   path 'DbtrAcct/Id',
                         bic2            varchar2(100)   path 'DbtrAgt/FinInstnId',
                         bic3            varchar2(100)   path 'CdtrAgt/FinInstnId',
                         nm2             varchar2(1000)  path 'Cdtr/Nm',
                         adrline21       varchar2(1000)  path 'Cdtr/PstlAdr/AdrLine[1]',
                         adrline22       varchar2(1000)  path 'Cdtr/PstlAdr/AdrLine[2]',
                         ctry2           varchar2(50)    path 'Cdtr/PstlAdr/Ctry',
                         iban2           varchar2(200)   path 'CdtrAcct/Id',
                         cdtrref         varchar2(1000)  path 'RmtInf/Strd/CdtrRefInf/CdtrRef',
                         addtlrmtinf     varchar2(1000)  path 'RmtInf/Strd/AddtlRmtInf'
               ) vThat last option could possibly get you some performance improvement as well.
Edited by: odie_63 on 14 sept. 2011 20:57

Similar Messages

  • Date insertion from large XML document (clob) into relation table very slow

    Hi Everybody!
    I'm working with Oracle 9.2.0.5 on Microsoft Windows Server 2003 Enterprise Edition.
    The server (a test server) is a Pentium 4 2.8 GHz, 1GB of RAM.
    I use a procedure called PARITOP_TRAITERXMLRESULTMASSE to insert the data contained in the pXMLDOC clob parameter in the table pTABLENAME. (You can see the format of the XML document below). The first step on this procedure is to verify that the XML document is not empty. If not, the procedure needs to add a node in the document, in every <ROW> tag. This added node is named “RST_ID”. It’s the foreign key of each record. I can retrieve the value of each <RST_ID> node in an other table in which the data has been previously added (by the calling procedure). When each of the <ROW> elements has been treated, the PARITOP_INSERTXML procedure is called. This procedure uses DBMS_XMLSAVE.INSERTXML to insert the data contained in the XML document in the specified table.
    (Below, you can see the code of my procedures.)
    With this information, can you tell me why this treatment is very very very slow with a large XML document and how I can improve it?
    Thank you for your help!
    Anne-Marie
    CREATE OR REPLACE PROCEDURE "PARITOP_TRAITERXMLRESULTMASSE" (
    pPRC_ID IN PARITOP_PARC.PRC_ID%TYPE,
    pRST_MONDE IN PARITOP_RESULTAT.RST_MONDE%TYPE,
    pXMLDOC IN CLOB,
    pTABLENAME IN VARCHAR2)
    AS
    Objectif :Insérer le contenu du XML passé en paramètre (pXMLDOC) à la table passée en paramètre (pTABLENAME)
    La table passée en paramètre doit être une table ayant comme clé étrangère le champs "RST_ID" .
    (Le noeud RST_ID est donc ajouté à tous les document XML. Ce rst_id est
    déterminé à partir de la table PARITOP_RESULTAT grâce à pPRC_ID et
    pRstMonde fournis en paramètre)
    result_doc CLOB;
    XMLDOMDOC XDB.DBMS_XMLDOM.DOMDOCUMENT;
    NODE_ROWSET DBMS_XMLDOM.DOMNODE;
    NODE_ROW DBMS_XMLDOM.DOMNODE;
    vUE_ID PARITOP_RESULTAT.UE_ID%TYPE;
    vRST_ID PARITOP_RESULTAT.RST_ID%TYPE;
    nodeList DBMS_XMLDOM.DOMNODELIST;
    BEGIN
    BEGIN
    vUE_ID := 0;
    vRST_ID := 0;
    XMLDOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT(pXMLDOC);
    IF NOT GESTXML_PKG.FN_PARITOP_DOCUMENT_IS_NULL(XMLDOMDOC) THEN
    NODE_ROWSET := DBMS_XMLDOM.item(DBMS_XMLDOM.GETCHILDNODES (DBMS_XMLDOM.MAKENODE(XMLDOMDOC)),0);
    for i in 0..dbms_xmldom.getLength(DBMS_XMLDOM.getchildnodes(NODE_ROWSET))-1 loop
    NODE_ROW := DBMS_XMLDOM.ITEM(DBMS_XMLDOM.GETCHILDNODES(NODE_ROWSET), i) ;
    nodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(DBMS_XMLDOM.makeelement(NODE_ROW) , 'UE_ID');
    IF vUE_ID <> DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0))) THEN
    vUE_ID := DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0)));
    --on ramasse le rst_id
    SELECT RST_ID INTO vRST_ID
    FROM PARITOP_RESULTAT RST
    WHERE RST.PRC_ID = pPRC_ID
    AND RST.UE_ID = vUE_ID
    AND RST.RST_MONDE = pRST_MONDE
    AND RST_A_SUPPRIMER = 0;
    END IF;
    GESTXML_PKG.PARITOP_ADDNODETOROW(XMLDOMDOC, NODE_ROW, 'RST_ID', vRST_ID);
    end loop;
    RESULT_DOC := ' '; --à garder, pour ne pas que ca fasse d'erreur lors du WriteToClob.
    dbms_xmldom.writeToClob(DBMS_XMLDOM.MAKENODE(XMLDOMDOC), RESULT_DOC);
    --Insertion du document XML dans la table "tableName"
    GESTXML_PKG.PARITOP_INSERTXML(RESULT_DOC, pTABLENAME);
    DBMS_XMLDOM.FREEDOCUMENT( XMLDOMDOC);
    end if;
    EXCEPTION
    […exception treatement…]
    END;
    END;
    The format of a XML clob is :
    <ROWSET>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6223</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>92.307692307692307</CMP_INDICESELECTION>
    <CMP_PVRES>94900</CMP_PVRES>
    <CMP_PVAJUSTE>72678.017699115066</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>72678.017699115095</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>72678.017699115037</CMP_PVAJUSTEMAX>
    <CMP_PV>148000</CMP_PV>
    <CMP_VALROLE>129400</CMP_VALROLE>
    <CMP_PVRESECART>4790</CMP_PVRESECART>
    <CMP_PVRHAB>101778.01769911509</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>148000</CMP_PVA>
    </ROW>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6235</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>76.92307692307692</CMP_INDICESELECTION>
    <CMP_PVRES>117800</CMP_PVRES>
    <CMP_PVAJUSTE>118080</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>118080</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>118080</CMP_PVAJUSTEMAX>
    <CMP_PV>172000</CMP_PV>
    <CMP_VALROLE>134800</CMP_VALROLE>
    <CMP_PVRESECART>0</CMP_PVRESECART>
    <CMP_PVRHAB>147180</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>172000</CMP_PVA>
    </ROW>
    </ROWSET>
    PARITOP_COMPARABLE TABLE :
    RST_ID NUMBER(10) NOT NULL,
    VEN_ID NUMBER(10) NOT NULL,
    CMP_SELMAN NUMBER(1) NOT NULL,
    CMP_UTILISE NUMBER(1) NOT NULL,
    CMP_INDICESELECTION FLOAT(53) NOT NULL,
    CMP_PVRES FLOAT(53) NULL,
    CMP_PVAJUSTE FLOAT(53) NULL,
    CMP_PVRHAB FLOAT(53) NULL,
    CMP_TVM FLOAT(53) NULL
    ROCEDURE PARITOP_INSERTXML (xmlDoc IN clob, tableName IN VARCHAR2)
    AS
    insCtx DBMS_XMLSave.ctxType;
    rowss number;
    BEGIN
    --permet d'insérer les champs du XML dans la table passée en paramètre.
    --il suffit que les champs XML aient le même nom que les champs de la table
    BEGIN
    insCtx := DBMS_XMLSave.newContext(tableName); -- get context handle
    DBMS_XMLSAVE.SETDATEFORMAT( insCtx, 'yyyy-MM-dd HH:mm:ss');--attention, case sensitive
    DBMS_XMLSAVE.setIgnoreCase(insCtx, 1);
    rowss := DBMS_XMLSAVE.INSERTXML(insCtx , xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    EXCEPTION
    […]
    END;
    END;
    PROCEDURE PARITOP_ADDNODETOROW (
    XMLDOMDOC DBMS_XMLDOM.DOMDOCUMENT,
    NODE_ROW dbms_xmldom.DOMNode,
    NOM_NOEUD VARCHAR2,
    VALEUR_NOEUD VARCHAR2)
    AS
    --PERMET D'AJOUTER UN NOEUD AVEC 1 SEULE VALEUR DANS une ROW D'UN XML.
    --UTILE SURTOUT POUR LES CLÉS ÉTRANGÈRES
    domElemAInserer DBMS_XMLDOM.DOMELEMENT;
    NODE dbms_xmldom.DOMNode;
    NODE_TMP dbms_xmldom.DOMNode;
    BEGIN
    domElemAInserer := DBMS_XMLDOM.createElement(XMLDOMDOC, NOM_NOEUD) ;
    NODE := DBMS_XMLDOM.MAKENODE(domElemAInserer); --cast
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE_ROW,NODE);
    NODE_TMP := DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.CREATETEXTNODE(XMLDOMDOC, VALEUR_NOEUD ) );
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE,NODE_TMP );
    END;

    Hi Everybody!
    I'm working with Oracle 9.2.0.5 on Microsoft Windows Server 2003 Enterprise Edition.
    The server (a test server) is a Pentium 4 2.8 GHz, 1GB of RAM.
    I use a procedure called PARITOP_TRAITERXMLRESULTMASSE to insert the data contained in the pXMLDOC clob parameter in the table pTABLENAME. (You can see the format of the XML document below). The first step on this procedure is to verify that the XML document is not empty. If not, the procedure needs to add a node in the document, in every <ROW> tag. This added node is named “RST_ID”. It’s the foreign key of each record. I can retrieve the value of each <RST_ID> node in an other table in which the data has been previously added (by the calling procedure). When each of the <ROW> elements has been treated, the PARITOP_INSERTXML procedure is called. This procedure uses DBMS_XMLSAVE.INSERTXML to insert the data contained in the XML document in the specified table.
    (Below, you can see the code of my procedures.)
    With this information, can you tell me why this treatment is very very very slow with a large XML document and how I can improve it?
    Thank you for your help!
    Anne-Marie
    CREATE OR REPLACE PROCEDURE "PARITOP_TRAITERXMLRESULTMASSE" (
    pPRC_ID IN PARITOP_PARC.PRC_ID%TYPE,
    pRST_MONDE IN PARITOP_RESULTAT.RST_MONDE%TYPE,
    pXMLDOC IN CLOB,
    pTABLENAME IN VARCHAR2)
    AS
    Objectif :Insérer le contenu du XML passé en paramètre (pXMLDOC) à la table passée en paramètre (pTABLENAME)
    La table passée en paramètre doit être une table ayant comme clé étrangère le champs "RST_ID" .
    (Le noeud RST_ID est donc ajouté à tous les document XML. Ce rst_id est
    déterminé à partir de la table PARITOP_RESULTAT grâce à pPRC_ID et
    pRstMonde fournis en paramètre)
    result_doc CLOB;
    XMLDOMDOC XDB.DBMS_XMLDOM.DOMDOCUMENT;
    NODE_ROWSET DBMS_XMLDOM.DOMNODE;
    NODE_ROW DBMS_XMLDOM.DOMNODE;
    vUE_ID PARITOP_RESULTAT.UE_ID%TYPE;
    vRST_ID PARITOP_RESULTAT.RST_ID%TYPE;
    nodeList DBMS_XMLDOM.DOMNODELIST;
    BEGIN
    BEGIN
    vUE_ID := 0;
    vRST_ID := 0;
    XMLDOMDOC := DBMS_XMLDOM.NEWDOMDOCUMENT(pXMLDOC);
    IF NOT GESTXML_PKG.FN_PARITOP_DOCUMENT_IS_NULL(XMLDOMDOC) THEN
    NODE_ROWSET := DBMS_XMLDOM.item(DBMS_XMLDOM.GETCHILDNODES (DBMS_XMLDOM.MAKENODE(XMLDOMDOC)),0);
    for i in 0..dbms_xmldom.getLength(DBMS_XMLDOM.getchildnodes(NODE_ROWSET))-1 loop
    NODE_ROW := DBMS_XMLDOM.ITEM(DBMS_XMLDOM.GETCHILDNODES(NODE_ROWSET), i) ;
    nodeList := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(DBMS_XMLDOM.makeelement(NODE_ROW) , 'UE_ID');
    IF vUE_ID <> DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0))) THEN
    vUE_ID := DBMS_XMLDOM.GETNODEVALUE(DBMS_XMLDOM.GETFIRSTCHILD(DBMS_XMLDOM.ITEM(nodeList, 0)));
    --on ramasse le rst_id
    SELECT RST_ID INTO vRST_ID
    FROM PARITOP_RESULTAT RST
    WHERE RST.PRC_ID = pPRC_ID
    AND RST.UE_ID = vUE_ID
    AND RST.RST_MONDE = pRST_MONDE
    AND RST_A_SUPPRIMER = 0;
    END IF;
    GESTXML_PKG.PARITOP_ADDNODETOROW(XMLDOMDOC, NODE_ROW, 'RST_ID', vRST_ID);
    end loop;
    RESULT_DOC := ' '; --à garder, pour ne pas que ca fasse d'erreur lors du WriteToClob.
    dbms_xmldom.writeToClob(DBMS_XMLDOM.MAKENODE(XMLDOMDOC), RESULT_DOC);
    --Insertion du document XML dans la table "tableName"
    GESTXML_PKG.PARITOP_INSERTXML(RESULT_DOC, pTABLENAME);
    DBMS_XMLDOM.FREEDOCUMENT( XMLDOMDOC);
    end if;
    EXCEPTION
    […exception treatement…]
    END;
    END;
    The format of a XML clob is :
    <ROWSET>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6223</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>92.307692307692307</CMP_INDICESELECTION>
    <CMP_PVRES>94900</CMP_PVRES>
    <CMP_PVAJUSTE>72678.017699115066</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>72678.017699115095</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>72678.017699115037</CMP_PVAJUSTEMAX>
    <CMP_PV>148000</CMP_PV>
    <CMP_VALROLE>129400</CMP_VALROLE>
    <CMP_PVRESECART>4790</CMP_PVRESECART>
    <CMP_PVRHAB>101778.01769911509</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>148000</CMP_PVA>
    </ROW>
    <ROW>
    <PRC_ID>193</PRC_ID>
    <UE_ID>8781</UE_ID>
    <VEN_ID>6235</VEN_ID>
    <RST_MONDE>0</RST_MONDE>
    <CMP_SELMAN>0</CMP_SELMAN>
    <CMP_INDICESELECTION>76.92307692307692</CMP_INDICESELECTION>
    <CMP_PVRES>117800</CMP_PVRES>
    <CMP_PVAJUSTE>118080</CMP_PVAJUSTE>
    <CMP_PVAJUSTEMIN>118080</CMP_PVAJUSTEMIN>
    <CMP_PVAJUSTEMAX>118080</CMP_PVAJUSTEMAX>
    <CMP_PV>172000</CMP_PV>
    <CMP_VALROLE>134800</CMP_VALROLE>
    <CMP_PVRESECART>0</CMP_PVRESECART>
    <CMP_PVRHAB>147180</CMP_PVRHAB>
    <CMP_UTILISE>1</CMP_UTILISE>
    <CMP_TVM>1</CMP_TVM>
    <CMP_PVA>172000</CMP_PVA>
    </ROW>
    </ROWSET>
    PARITOP_COMPARABLE TABLE :
    RST_ID NUMBER(10) NOT NULL,
    VEN_ID NUMBER(10) NOT NULL,
    CMP_SELMAN NUMBER(1) NOT NULL,
    CMP_UTILISE NUMBER(1) NOT NULL,
    CMP_INDICESELECTION FLOAT(53) NOT NULL,
    CMP_PVRES FLOAT(53) NULL,
    CMP_PVAJUSTE FLOAT(53) NULL,
    CMP_PVRHAB FLOAT(53) NULL,
    CMP_TVM FLOAT(53) NULL
    ROCEDURE PARITOP_INSERTXML (xmlDoc IN clob, tableName IN VARCHAR2)
    AS
    insCtx DBMS_XMLSave.ctxType;
    rowss number;
    BEGIN
    --permet d'insérer les champs du XML dans la table passée en paramètre.
    --il suffit que les champs XML aient le même nom que les champs de la table
    BEGIN
    insCtx := DBMS_XMLSave.newContext(tableName); -- get context handle
    DBMS_XMLSAVE.SETDATEFORMAT( insCtx, 'yyyy-MM-dd HH:mm:ss');--attention, case sensitive
    DBMS_XMLSAVE.setIgnoreCase(insCtx, 1);
    rowss := DBMS_XMLSAVE.INSERTXML(insCtx , xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    EXCEPTION
    […]
    END;
    END;
    PROCEDURE PARITOP_ADDNODETOROW (
    XMLDOMDOC DBMS_XMLDOM.DOMDOCUMENT,
    NODE_ROW dbms_xmldom.DOMNode,
    NOM_NOEUD VARCHAR2,
    VALEUR_NOEUD VARCHAR2)
    AS
    --PERMET D'AJOUTER UN NOEUD AVEC 1 SEULE VALEUR DANS une ROW D'UN XML.
    --UTILE SURTOUT POUR LES CLÉS ÉTRANGÈRES
    domElemAInserer DBMS_XMLDOM.DOMELEMENT;
    NODE dbms_xmldom.DOMNode;
    NODE_TMP dbms_xmldom.DOMNode;
    BEGIN
    domElemAInserer := DBMS_XMLDOM.createElement(XMLDOMDOC, NOM_NOEUD) ;
    NODE := DBMS_XMLDOM.MAKENODE(domElemAInserer); --cast
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE_ROW,NODE);
    NODE_TMP := DBMS_XMLDOM.MAKENODE(DBMS_XMLDOM.CREATETEXTNODE(XMLDOMDOC, VALEUR_NOEUD ) );
    NODE := DBMS_XMLDOM.APPENDCHILD(NODE,NODE_TMP );
    END;

  • Storing XML data in CLOB and relational tables

    I would like to ask whether there is a possibility to store XML data using normal relational tables and CLOBs in the same time. For example I have some XML data (structured data) which I would like update very often and some which are only a kind of description. I found something about it in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm . But I do not know how to use Oracle8i views and some functionality of XML SQL Utility to retrieve XML data in one file.
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Maciej Marczukajtis ([email protected]):
    I would like to ask whether there is a possibility to store XML data using normal relational tables and CLOBs in the same time. For example I have some XML data (structured data) which I would like update very often and some which are only a kind of description. I found something about it in http://technet.oracle.com/tech/xml/infoocs/otnwp/about_oracle_xml_products.htm . But I do not know how to use Oracle8i views and some functionality of XML SQL Utility to retrieve XML data in one file.<HR></BLOCKQUOTE>
    Czesc Maciek,
    There are some good examples with XSQL Servlet. From what I understand you have one XML file and you need to save a portion of document in relational tables and other portion in CLOB.
    Yes, you can do that.
    You can do it many ways. I can suggest (2).
    1. Use the views
    2. call your java procedure that will do
    the xml processing, brake it down and insert
    releval frogments into different tables/columns
    null

  • How to extract data from xml and insert into Oracle table

    Hi,
    I have a large xml file. which will have hundreds of the following transaction tags having column names and there values.
    There is a table one of the schema with coulums "actualCostRate","billRate"....etc.
    I need to extract the values of these columns and insert into the table
    <Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuUK" chargeCode="LCOCD1" externalID="L-RESCODE_UK1-PROJ_UK_CNT_GBP-37289-8" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-12" transactionType="L" units="11" taskID="5017601" inputTypeCode="SALES" groupId="123" voucherNumber="ABCVDD" transactionClass="ABCD"/>
    <Transaction actualCostRate="0" billRate="0" chargeable="1" clientID="NikuEU" chargeCode="LCOCD1" externalID="L-RESCODE_US1-PROJ_EU_STD2-37291-4" importStatus="N" projectID="TESTPROJ" resourceID="admin" transactionDate="2002-02-04" transactionType="L" units="4" taskID="5017601" inputTypeCode="SALES" groupId="124" voucherNumber="EEE222" transactionClass="DEFG"/>

    Re: Insert from XML to relational table
    http://www.google.ae/search?hl=ar&q=extract+data+from+xml+and+insert+into+Oracle+table+&btnG=%D8%A8%D8%AD%D8%AB+Google&meta=

  • Select data from an XML Column in a Relational Table

    Hi guys,
    I read a lot of documentation from Oracle how to select xml nodes from an XML Table. The following statement works perfectly for an XML table.
    select extract(OBJECT_VALUE, '/loop/loop_data/description') "DESCRIPTION"
    from loop_table
    where xmlexists('/loop/loop_data[type_code="212"]' PASSING OBJECT_VALUE);
    BUT: how to select xml nodes (data) from a relational table with an XML column???
    I'm interested in the xml data.
    Thanks!
    Miro

    I've tried the same but i don't get any results
    WITH BOL_JMS_MESSAGES_TMP AS
    (SELECT 1 pk,
    XMLTYPE('<MESSAGE_ENVELOPE>
    <ORDER>
    <DIRECT_TURNOVER>N</DIRECT_TURNOVER>
    <DATE_PLACED>2010-05-06T17:14:35.189+02:00</DATE_PLACED>
    <PAYMENT_TYPE>02</PAYMENT_TYPE>
    <ACCOUNT_NUMBER>108317412</ACCOUNT_NUMBER>
    <GIFT_FLAG>N</GIFT_FLAG>
    <ID>7788783900</ID>
    <NETPRICE>117.21</NETPRICE>
    <VAT>7.69</VAT>
    <TOTALPRICE>126.85</TOTALPRICE>
    <SHIPHAND_COSTS>1.64</SHIPHAND_COSTS>
    <SHIPHAND_VAT>0.31</SHIPHAND_VAT>
    <SHIPEQUALBILL_FLAG>Y</SHIPEQUALBILL_FLAG>
    <SHIPPING_METHOD>01</SHIPPING_METHOD>
    </ORDER>
    </MESSAGE_ENVELOPE>') rnd_col
    from dual
    select extract(rnd_col, '/message_envelope/order/direct_turnover/date_placed/payment_type/account_number/gift_flag/id/netprice/vat/totalprice/shiphand_costs/shiphand_vat/shipequalbill_flag/SHIPPING_METHOD') "Payment type"
    FROM BOL_JMS_MESSAGES_TMP
    WHERE existsNode(rnd_col,'/message_envelope') = 1;
    No rows.
    Eventually i want to update the payment type from 02 to 00.

  • XML BLOB/CLOB to relational structure

    Hi
    I would like peoples views on the best approach to the folllowing scenario
    We are implementing a new payments engine (major bank), the vendors DB is a mix of normal relational tables & XML including XML CLOB/BLOB. In the latter case, the original incoming payment message and the enriched outgoing payment message is stored as XML CLOB. The vendor has no OOTB reporting capabilities so our approach is to replicate the production database using GoldenGate. We then plan to cretae a fully relational oracle database as an ODS (near real time) with B.O sitting over the top for reporting. We will use Oracle Data Integrator to extract the data from the rplicated copy of the live DB every 10 mins, shred the XML clob components and store in normal relational tables in the ODI.
    Does anyone see major problems with this approach and can anyone suggest a better approach

    Hi
    I would like peoples views on the best approach to the folllowing scenario
    We are implementing a new payments engine (major bank), the vendors DB is a mix of normal relational tables & XML including XML CLOB/BLOB. In the latter case, the original incoming payment message and the enriched outgoing payment message is stored as XML CLOB. The vendor has no OOTB reporting capabilities so our approach is to replicate the production database using GoldenGate. We then plan to cretae a fully relational oracle database as an ODS (near real time) with B.O sitting over the top for reporting. We will use Oracle Data Integrator to extract the data from the rplicated copy of the live DB every 10 mins, shred the XML clob components and store in normal relational tables in the ODI.
    Does anyone see major problems with this approach and can anyone suggest a better approach

  • Approach to parse large number of XML files into the relational table.

    We are exploring the option of XML DB for processing a large number of files coming same day.
    The objective is to parse the XML file and store in multiple relational tables. Once in relational table we do not care about the XML file.
    The file can not be stored on the file server and need to be stored in a table before parsing due to security issues. A third party system will send the file and will store it in the XML DB.
    File size can be between 1MB to 50MB and high performance is very much expected other wise the solution will be tossed.
    Although we do not have XSD, the XML file is well structured. We are on 11g Release 2.
    Based on the reading this is what my approach.
    1. CREATE TABLE XML_DATA
    (xml_col XMLTYPE)
    XMLTYPE xml_col STORE AS SECUREFILE BINARY XML;
    2. Third party will store the data in XML_DATA table.
    3. Create XMLINDEX on the unique XML element
    4. Create views on XMLTYPE
    CREATE OR REPLACE FORCE VIEW V_XML_DATA(
       Stype,
       Mtype,
       MNAME,
       OIDT
    AS
       SELECT x."Stype",
              x."Mtype",
              x."Mname",
              x."OIDT"
       FROM   data_table t,
              XMLTABLE (
                 '/SectionMain'
                 PASSING t.data
                 COLUMNS Stype VARCHAR2 (30) PATH 'Stype',
                         Mtype VARCHAR2 (3) PATH 'Mtype',
                         MNAME VARCHAR2 (30) PATH 'MNAME',
                         OIDT VARCHAR2 (30) PATH 'OID') x;
    5. Bulk load the parse data in the staging table based on the index column.
    Please comment on the above approach any suggestion that can improve the performance.
    Thanks
    AnuragT

    Thanks for your response. It givies more confidence.
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    Example XML
    <SectionMain>
    <SectionState>Closed</SectionState>
    <FunctionalState>CP FINISHED</FunctionalState>
    <CreatedTime>2012-08</CreatedTime>
    <Number>106</Number>
    <SectionType>Reel</SectionType>
    <MachineType>CP</MachineType>
    <MachineName>CP_225</MachineName>
    <OID>99dd48cf-fd1b-46cf-9983-0026c04963d2</OID>
    </SectionMain>
    <SectionEvent>
    <SectionOID>99dd48cf-2</SectionOID>
    <EventName>CP.CP_225.Shredder</EventName>
    <OID>b3dd48cf-532d-4126-92d2</OID>
    </SectionEvent>
    <SectionAddData>
    <SectionOID>99dd48cf2</SectionOID>
    <AttributeName>ReelVersion</AttributeName>
    <AttributeValue>4</AttributeValue>
    <OID>b3dd48cf</OID>
    </SectionAddData>
    - <SectionAddData>
    <SectionOID>99dd48cf-fd1b-46cf-9983</SectionOID>
    <AttributeName>ReelNr</AttributeName>
    <AttributeValue>38</AttributeValue>
    <OID>b3dd48cf</OID>
    <BNCounter>
    <SectionID>99dd48cf-fd1b-46cf-9983-0026c04963d2</SectionID>
    <Run>CPFirstRun</Run>
    <SortingClass>84</SortingClass>
    <OutputStacker>D2</OutputStacker>
    <BNCounter>54605</BNCounter>
    </BNCounter>
    I was not aware of Virtual column but looks like we can use it and avoid creating views by just inserting directly into
    the staging table using virtual column.
    Suppose OID id is the unique identifier of each XML FILE and I created virtual column
    CREATE TABLE po_Virtual OF XMLTYPE
    XMLTYPE STORE AS BINARY XML
    VIRTUAL COLUMNS
    (OID_1 AS (XMLCAST(XMLQUERY('/SectionMain/OID'
    PASSING OBJECT_VALUE RETURNING CONTENT)
    AS VARCHAR2(30))));
    1. My question is how then I will write this query by NOT USING COLMUN XML_COL
    SELECT x."SECTIONTYPE",
    x."MACHINETYPE",
    x."MACHINENAME",
    x."OIDT"
    FROM po_Virtual t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                          <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
    MachineType VARCHAR2 (3) PATH 'MachineType',
    MachineName VARCHAR2 (30) PATH 'MachineName',
    OIDT VARCHAR2 (30) PATH 'OID') x;
    2. Insetead of creating the view then Can I do
    insert into STAGING_table_yyy ( col1 ,col2,col3,col4,
    SELECT x."SECTIONTYPE",
    x."MACHINETYPE",
    x."MACHINENAME",
    x."OIDT"
    FROM xml_data t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                         <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionType VARCHAR2 (30) PATH 'SectionType',
    MachineType VARCHAR2 (3) PATH 'MachineType',
    MachineName VARCHAR2 (30) PATH 'MachineName',
    OIDT VARCHAR2 (30) PATH 'OID') x
    where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
    insert into STAGING_table_yyy ( col1 ,col2,col3
    SELECT x."SectionOID",
    x."EventName",
    x."OIDT"
    FROM xml_data t,
    XMLTABLE (
    '/SectionMain'
    PASSING t.xml_col                         <--WHAT WILL PASSING HERE SINCE NO XML_COL
    COLUMNS SectionOID PATH 'SectionOID',
    EventName VARCHAR2 (30) PATH 'EventName',
    OID VARCHAR2 (30) PATH 'OID',
    ) x
    where oid_1 = '99dd48cf-fd1b-46cf-9983';<--VIRTUAL COLUMN
    Same insert for other tables usind the OID_1 virtual coulmn
    3. Finaly Once done how can I delete the XML document from XML.
    If I am using virtual column then I beleive it will be easy
    DELETE table po_Virtual where oid_1 = '99dd48cf-fd1b-46cf-9983';
    But in case we can not use the Virtual column how we can delete the data
    Thanks in advance
    AnuragT

  • Read data from xml files and  populate internal table

    Hi.
    How to read data from xml files into internal tables?
    Can u tell me the classes and methods to read xml data..
    Can u  explain it with a sample program...

    <pre>DATA itab_accontextdir TYPE TABLE OF ACCONTEXTDIR.
    DATA struct_accontextdir LIKE LINE OF itab_accontextdir.
    DATA l_o_error TYPE REF TO cx_root.
    DATA: filename type string ,
                 xmldata type xstring .
    DATA: mr      TYPE REF TO if_mr_api.
    mr = cl_mime_repository_api=>get_api( ).
    mr->get( EXPORTING  i_url     = 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'
                  IMPORTING  e_content = xmldata ).
    WRITE xmldata.
    TRY.
    CALL TRANSFORMATION id
          SOURCE XML xmldata
          RESULT shiva = itab_accontextdir.
      CATCH cx_root INTO l_o_error.
    ENDTRY.
    LOOP AT itab_accontextdir INTO struct_accontextdir.
        WRITE: / struct_accontextdir-context_id,
               struct_accontextdir-context_name,
               struct_accontextdir-context_type.
        NEW-LINE.
        ENDLOOP.</pre>
    <br/>
    Description:   
    In the above code snippet I am storing the data in an xml file(you know xml is used to store and transport data ) called 'xml_accontextdir.xml' that is uploaded into the MIME repository at path 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'.
    The below API is used to read a file in MIME repo and convert it into a string that is stored in ' xmldata'. (This is just a raw data that is got by appending the each line of  xml file).
    mr = cl_mime_repository_api=>get_api( ).
    mr->get( EXPORTING  i_url     = 'SAP/PUBLIC/BC/xml_files_accontext/xml_accontextdir.xml'
                  IMPORTING  e_content = xmldata ).
        Once the 'xmldata' string is available we use the tranformation to parse the xml string that we have got from the above API and convert it into the internal table.
    <pre>TRY.
    CALL TRANSFORMATION id
          SOURCE XML xmldata
          RESULT shiva = itab_accontextdir.
      CATCH cx_root INTO l_o_error.
    ENDTRY.</pre>
    Here the trasnsformation 'id ' is used to conververt the source xml 'xmldata' to resulting internal table itab_accontextdir, that have same structure as our xml file 'xml_accontextdir.xml'.  In the RESULT root of the xml file has to be specified. (In my the root is 'shiva'). 
    Things to be taken care:
    One of the major problem that occurs when reading the xml file is 'format not compatible with the internal table' that you are reading into internal table.  Iin order to get rid of this issue use one more tranformation to convert the data from the internal table into the xml file.    
    <pre>TRY.
          CALL TRANSFORMATION id
            SOURCE shiv = t_internal_tab
            RESULT XML xml.
        CATCH cx_root INTO l_o_error.
      ENDTRY.
      WRITE xml.
      NEW-LINE.</pre>
    <br/>
    This is the same transformation that we used above but the differnce is that the SOURCE and RESULT parameters are changed the source is now the internal table and result is *xml *string. Use xml browser that is available with the ABAP workbench to read the xml string displayed with proper indentation. In this way we get the format of xml file to be used that is compatable with the given internal table. 
    Thank you, Hope this will help you!!!
    Edited by: Shiva Prasad L on Jun 15, 2009 7:30 AM
    Edited by: Shiva Prasad L on Jun 15, 2009 11:56 AM
    Edited by: Shiva Prasad L on Jun 15, 2009 12:06 PM

  • Error  while export data from a xml file to an relational table

    Hi,
    I am Creating an ODI Project: Developing an ODI XML to Database Transformation Using Interface with ODI Constraint following this link
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/odi/odi_11g/odi_project_xml-to-table/odi_project_xml-to-table.htm
    This project executed successfully with some warning.*Target Table is automatically created in database and also populated with data*.But when I right-click Target Datastore(in Mapping Tab of the Interface), and then select Data to View Data that needs to be inserted in the target table. I get some error like this:-
    Execution of Query Failed.
    Details:-
    See com.borland.dx.dataset.DataSetException error code: BASE+62
    com.borland.dx.dataset.DataSetException: Execution of query failed.
         at com.borland.dx.dataset.DataSetException.a(Unknown Source)
         at com.borland.dx.dataset.DataSetException.queryFailed(Unknown Source)
         at com.borland.dx.sql.dataset.QueryProvider.a(Unknown Source)
         at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
         at com.borland.dx.dataset.StorageDataSet.refresh(Unknown Source)
         at com.borland.dx.sql.dataset.QueryDataSet.refresh(Unknown Source)
         at com.sunopsis.graphical.frame.DwgDataFrame.initialize(DwgDataFrame.java:368)
         at com.sunopsis.graphical.frame.DwgDataFrame.<init>(DwgDataFrame.java:77)
         at oracle.odi.ui.etlmodeler.diag.inspector.pane.popup.DiagramActionDispayDataTarget.actionPerformed(DiagramActionDispayDataTarget.java:91)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1223)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1264)
         at java.awt.Component.processMouseEvent(Component.java:6263)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
         at java.awt.Component.processEvent(Component.java:6028)
         at java.awt.Container.processEvent(Container.java:2041)
         at java.awt.Component.dispatchEventImpl(Component.java:4630)
         at java.awt.Container.dispatchEventImpl(Container.java:2099)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
         at java.awt.Container.dispatchEventImpl(Container.java:2085)
         at java.awt.Window.dispatchEventImpl(Window.java:2478)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Chained exception:
    java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:947)
         at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1283)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1441)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3823)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1671)
         at com.borland.dx.sql.dataset.o.f(Unknown Source)
         at com.borland.dx.sql.dataset.QueryProvider.e(Unknown Source)
         at com.borland.dx.sql.dataset.JdbcProvider.provideData(Unknown Source)
         at com.borland.dx.dataset.StorageDataSet.refresh(Unknown Source)
         at com.borland.dx.sql.dataset.QueryDataSet.refresh(Unknown Source)
         at com.sunopsis.graphical.frame.DwgDataFrame.initialize(DwgDataFrame.java:368)
         at com.sunopsis.graphical.frame.DwgDataFrame.<init>(DwgDataFrame.java:77)
         at oracle.odi.ui.etlmodeler.diag.inspector.pane.popup.DiagramActionDispayDataTarget.actionPerformed(DiagramActionDispayDataTarget.java:91)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1223)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1264)
         at java.awt.Component.processMouseEvent(Component.java:6263)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
         at java.awt.Component.processEvent(Component.java:6028)
         at java.awt.Container.processEvent(Container.java:2041)
         at java.awt.Component.dispatchEventImpl(Component.java:4630)
         at java.awt.Container.dispatchEventImpl(Container.java:2099)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
         at java.awt.Container.dispatchEventImpl(Container.java:2085)
         at java.awt.Window.dispatchEventImpl(Window.java:2478)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Please Help

    Michael R wrote:
    The target table will be created when you execute the interface, if you set the option on the flow tab as instructed in step #6 of the "Setting up ODI Constraint on CLIENT Datastore" Section.
    Option     Value
    CREATE_TARG_TABLE      trueHi Michel,
    This was not my required answer.I am sorry that I was unable to clarify my question.Actually
    +This project executed successfully with some warning.Target Table is automatically created in database and also populated with data.But when I right-click Target Datastore(in >Mapping Tab of the Interface), and then select Data to View Data that needs to be inserted in the target table.I get some error like this:-...+This above line is the result of my project my problem is
    when I right-click Target Datastore(in Mapping Tab of the Interface), and then select Data to View Data that already inserted in the target table.Is not shown by the view data operation.
    I meant to say I am facing this error
    At the10(1010 written) step of
    Creating a New ODI Interface to Perform XML File to RDBMS Table Transformation
    wehre it says
    Open the Interface tab. Select Mapping tab, right-click Target Datastore - CLIENT, and then select Data. View Data inserted in the target table. Close Data Editor. Close the tabs...
    In my case when I use my sqldeveloper I can see data successfully inserted in my target table and also in error table (data that can't satisfy the constraint) .But I was unable to check this by following the above mentioned 10 th step and got this error.
    Thanks

  • Select fields from XML in CLOB column

    Hi,
    I have the following XML stored in a table as CLOB field. What i want is to select specific fields into Relational Data.
    <?xml version=1.0 encoding=UTF-8?>
    <msgContext>
        <JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
            <jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
            <jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
            <jms1:JMSExpiration>0</jms1:JMSExpiration>
            <jms1:JMSRedelivered>false</jms1:JMSRedelivered>
            <jms1:JMSPriority>4</jms1:JMSPriority>
        </JMSHeaders>
        <OtherProperties>
            <auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
            <auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
            <correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
            <auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
            <auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
            <auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
            <auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
            <auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
            <ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
                <ns0:dp-logpoint>response</ns0:dp-logpoint>
                <ns0:dp-target-url/>
                <ns0:dp-port>20565</ns0:dp-port>
                <ns0:dp-uri>/comp_am</ns0:dp-uri>
                <ns0:dp-size>1365</ns0:dp-size>
                <ns0:dp-replytoengine/>
            </ns0:auditInfo>
        </OtherProperties>
    </msgContext>I tried to use the xml_query below with no luck :
    SELECT  x.auditPartnerId,
                 x.auditServiceId
       FROM source s
         , XMLTable(
             '/msgContext/OtherProperties'
              passing s.messagetext
              columns
              auditPartnerId   VARCHAR2(20) PATH 'auditPartnerId'
            , auditServiceId     VARCHAR2(20) PATH 'auditServiceId'
            ) x;Any help appreciated

    alekons wrote:
    Any help appreciatedYou will have to convert it to xmltype first. See below:
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Release 10.2.0.5.0 - Production
    PL/SQL Release 10.2.0.5.0 - Production
    CORE     10.2.0.5.0     Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    SQL> with src as ( select to_clob('<msgContext>
    <JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
    <jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
    <jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
    <jms1:JMSExpiration>0</jms1:JMSExpiration>
    <jms1:JMSRedelivered>false</jms1:JMSRedelivered>
    <jms1:JMSPriority>4</jms1:JMSPriority>
    </JMSHeaders>
    <OtherProperties>
    <auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
    <auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
    <correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
    <auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
    <auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
    <auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
    <auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
    <auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
    <ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
    <ns0:dp-logpoint>response</ns0:dp-logpoint>
    <ns0:dp-target-url/>
    <ns0:dp-port>20565</ns0:dp-port>
    <ns0:dp-uri>/comp_am</ns0:dp-uri>
    <ns0:dp-size>1365</ns0:dp-size>
    <ns0:dp-replytoengine/>
    </ns0:auditInfo>
    </OtherProperties>
    </msgContext>') as messagetext from dual )
    SELECT x.auditPartnerId,
    x.auditServiceId
    FROM src s
    , XMLTable(
    '/msgContext/OtherProperties'
    passing s.messagetext
    columns
    auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
    , AUDITSERVICEID VARCHAR2(20) PATH 'auditServiceId'
    ) x;
    36   37  passing s.messagetext
    ERROR at line 33:
    ORA-00932: inconsistent datatypes: expected - got CLOB
    with src as ( select xmltype(to_clob('<msgContext>
    <JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
    <jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
    <jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
    <jms1:JMSExpiration>0</jms1:JMSExpiration>
    <jms1:JMSRedelivered>false</jms1:JMSRedelivered>
    <jms1:JMSPriority>4</jms1:JMSPriority>
    </JMSHeaders>
    <OtherProperties>
    <auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
    <auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
    <correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
    <auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
    <auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
    <auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
    <auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
    <auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
    <ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
    <ns0:dp-logpoint>response</ns0:dp-logpoint>
    <ns0:dp-target-url/>
    <ns0:dp-port>20565</ns0:dp-port>
    <ns0:dp-uri>/comp_am</ns0:dp-uri>
    <ns0:dp-size>1365</ns0:dp-size>
    <ns0:dp-replytoengine/>
    </ns0:auditInfo>
    </OtherProperties>
    </msgContext>')) as messagetext from dual )
    SELECT x.auditPartnerId,
    x.auditServiceId
    FROM src s
    , XMLTable(
    '/msgContext/OtherProperties'
    passing s.messagetext
    columns
    auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
    , AUDITSERVICEID VARCHAR2(20) PATH 'auditServiceId'
    37  ) x;
    AUDITPARTNERID          AUDITSERVICEID
    010000000001189CC2BC Auth

  • Load XML Document/Data into relational Table

    Hi All,
    I have a requirement to load data in an XML file into an oracle db and subsequently split the contents into columns in an oracle table. This has to be done on the command line from a unix box which connects to a remote oracle DB.
    Can some one give me a step by step procedure to do this or point me in the right direction.
    thank you

    Hi,
    There can be many different way we can achieve this. Mainly depending on size of XML, complexity of XML and your use of that data (e.g. you just want to insert XML into relational or you want to write something and the generate new xmls later on).
    If you go to Oracle online documentation -> Oracle XML DB Developer's guide, first 3-4 chapters will give you what you need.
    Regards

  • Reading from XML file and updating the table ????

    Hi
    I have package which reads the hier.XML file and does Update inserts into the 5 tables
    i have table called MAIN_tbl with the column cur_date.
    The package kicks if this cur_date is one day less than the hier.XML file DT.
    Currently i m manually checking this date's to make sure the Main_tbl cur_date is n sync with
    hier.XML file DT.
    for example :- hier.xml file DT is "20091020" then main_table cur_date should be 10/19/2009
    in order to kicks of the pakage.
    what i m looking to do ??
    compare the hier.xml DT with the main_table cur_date,
    if cur_date is -1(Preivous day) of hier.xml DT then run hier_pkg(Package)
    if not then update main_table cur_date to -1(previous day) of the hier.xml DATE
    Then later write the above logic to update the main_table in a procedure, and
    then call the package from the procedure.
    below are the top few lines of the hier.XML file which is relevant to the one which we are trying to do
    <?xml version = '1.0'?>
    <HIER_POSTING num ="111" HIER_TYP="CD" DT="20091020" Global="Y">
    FYI : The hier.XML file is located in UNIX space.
    How do i accomplish this. any idea ????
    Thank you so much in advance. For giving a thought on this problem!!!

    Any thought on this guys ???
    Thanks!!

  • How to parse and retrieve records from xml files into columns in Table

    Hi
    I attached the thing what i tried.
    Table to hold the XML COntent:
    create table xmlfile(xml_con sys.xmltype);
    Inserting Xml file content into the Above table:
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><name>RAM</name><age>23</age></Root>'))
    SQL> select * from xmlfile;
    XML_CON
    <Root>
    <name>RAM</name>
    <age>23</age>
    </Root>
    SQL> select extractValue(xml_con, '/Root/name') content from xmlfile;
    CONTENT
    RAM
    This one works fine
    But if the file content is as below( contains MUltiple Records)
    insert into xmlfile values(sys.xmltype.CreateXml('<Root><Record><name>RAM</name><age>23</age></Record><Record><name>SAM</name><age>23</age></Record></Root>'))
    SQL> select extractValue(xml_con, '/Root/Record/name') content from xmlfile;
    ERROR at line 1:
    ORA-19025: EXTRACTVALUE returns value of only one node
    Can anyone help me 4 this issue-How to extract multiple records from the XML file inthis manner(from PL/SQL without using JAVA)
    OR
    If there is anyother way to do this please tell me?

    SQL> SELECT EXTRACTVALUE (COLUMN_VALUE, '//name') NAME,
           EXTRACTVALUE (COLUMN_VALUE, '//age') age
      FROM TABLE
              (XMLSEQUENCE
                  (EXTRACT
                      (XMLTYPE
                          ('<Root>
                              <Record>
                                <name>RAM</name>
                                <age>23</age>
                              </Record>
                              <Record>
                                <name>SAM</name>
                                <age>23</age>
                              </Record>
                            </Root>'
                       '/Root/Record'
    NAME       AGE      
    RAM        23       
    SAM        23       
    2 rows selected.

  • Querying XML data in  Object Relational tables

    Hi,
    Can someone help me?
    I have registered the purchaseorder.xsd in my database schema.
    [ http://www.oracle.com/technology/oramag/oracle/03-jul/o43xml.html ]
    declare
    l_bfile bfile;
    begin
    l_bfile := bfilename(
    'XMLSAMP', 'purchaseOrder.xsd');
    dbms_lob.open(l_bfile);
    dbms_xmlschema.registerschema('http://localhost:8080/purchaseOrder.xsd', l_bfile);
    dbms_lob.close(l_bfile);
    end;
    This has created a table "PURCHASEORDER"
    SYS_NC_ROWINFO$ SYS.XMLTYPE
    It has also created object types.
    select object_name from user_objects where object_type = 'TYPE' and object_name like 'XDBPO%'
    XDBPO_ACTIONS_TYPE
    XDBPO_ACTION_COLLECTION
    XDBPO_ACTION_TYPE
    XDBPO_LINEITEMS_TYPE
    XDBPO_LINEITEM_TYPE
    XDBPO_PART_TYPE
    XDBPO_REJECTION_TYPE
    XDBPO_SHIPINSTRUCTIONS_TYPE
    XDBPO_TYPE
    I have also inserted an xml into that table.
    INSERT INTO "PURCHASEORDER"
    VALUES
    xmltype
    getFileContent('ADAMS-20011127121040988PST.xml','XMLSAMP')
    Now how do I retrieve the data from this table and the other object types?
    Is extractvalue the only method? I have gone thru examples in the net but everything uses the element names in xml document and not the object type names.
    For example to retreive the lineitem details, this query can be used
    SELECT extractValue(value(d),'/Description')
    FROM "PURCHASEORDER" p,
    table (xmlsequence(extract(p.SYS_NC_ROWINFO$,'/PurchaseOrder/LineItems/LineItem/Description'))) d
    But I want to retreive it from "XDBPO_LINEITEM_TYPE".
    Is this possible?
    Can someone help me please?
    Thanks in advance.
    Jay

    #1. If you had taken the time to read some of the other posts in the forum all of the answers you needed were all there..
    #2. As PM's we are not expected to spend a lot of time dealing with the forums. In general we are expected only to step in and answer the questions that are not easily answered by carefully reading existing posts or deal with cases were the wrong answer is supplied.
    #3. I'm technically on vacation, and posted to that effect last week, so pushing for an answer is not at all appreciated...
    #4. The problem is extremely simple, at least as stated in your simple example.
    Given the schema.. Note It's been annotated
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
         <xs:element name="Bill">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="InvCtlN"/>
                        <xs:element ref="MedBU"/>
                        <xs:element ref="Lineitem" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="InvCtlN">
              <xs:simpleType>
                   <xs:restriction base="xs:byte">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="LineCode">
              <xs:simpleType>
                   <xs:restriction base="xs:int">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="Lineitem">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="Type"/>
                        <xs:element ref="LineCode"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="MedBU">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
         <xs:element name="SampleFile" xdb:defaultTable="SAMPLE_FILE_TABLE">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="Bill" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="Type">
              <xs:simpleType>
                   <xs:restriction base="xs:string">
                   </xs:restriction>
              </xs:simpleType>
         </xs:element>
    </xs:schema>and the following instance
    <SampleFile xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="testcase.xsd">
         <Bill>
              <InvCtlN>1</InvCtlN>
              <MedBU>ABC</MedBU>
              <Lineitem>
                   <Type>P1</Type>
                   <LineCode>99214</LineCode>
              </Lineitem>
         </Bill>
         <Bill>
              <InvCtlN>2</InvCtlN>
              <MedBU>DEF</MedBU>
              <Lineitem>
                   <Type>P2</Type>
                   <LineCode>99215</LineCode>
              </Lineitem>
              <Lineitem>
                   <Type>P3</Type>
                   <LineCode>99216</LineCode>
              </Lineitem>
         </Bill>
         <Bill>
              <InvCtlN>3</InvCtlN>
              <MedBU>HJK</MedBU>
              <Lineitem>
                   <Type>P4</Type>
                   <LineCode>99217</LineCode>
              </Lineitem>
         </Bill>
    </SampleFile>The following appears to be what you are looking for
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:53 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool registerSchema_&4..log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> declare
      2    result boolean;
      3  begin
      4    result := dbms_xdb.createResource('/home/&1/xsd/&4',
      5                                      bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
      6  end;
      7  /
    old   4:   result := dbms_xdb.createResource('/home/&1/xsd/&4',
    new   4:   result := dbms_xdb.createResource('/home/OTNTEST/xsd/testcase.xsd',
    old   5:                                    bfilename(USER,'&4'),nls_charset_id('AL32UTF8'));
    new   5:                                    bfilename(USER,'testcase.xsd'),nls_charset_id('AL32UTF8'));
    PL/SQL procedure successfully completed.
    SQL> commit
      2  /
    Commit complete.
    SQL> alter session set events='31098 trace name context forever'
      2  /
    Session altered.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      schemaURL => '&3',
      5      schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
      6      local     => TRUE,
      7      genTypes  => TRUE,
      8      genBean   => FALSE,
      9      genTables => &5
    10    );
    11  end;
    12  /
    old   4:     schemaURL => '&3',
    new   4:     schemaURL => 'testcase.xsd',
    old   5:     schemaDoc => xdbURIType('/home/&1/xsd/&4').getClob(),
    new   5:     schemaDoc => xdbURIType('/home/OTNTEST/xsd/testcase.xsd').getClob(),
    old   9:     genTables => &5
    new   9:     genTables => TRUE
    PL/SQL procedure successfully completed.
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:55 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool insertFile_&3..log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> set timing on
    SQL> set long 10000
    SQL> --
    SQL> insert into &4 values (xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
      2  /
    old   1: insert into &4 values (xmltype(bfilename(USER,'&3'),nls_charset_id('AL32UTF8')))
    new   1: insert into SAMPLE_FILE_TABLE values (xmltype(bfilename(USER,'testcase.xml'),nls_charset_id('AL32UTF8')
    1 row created.
    Elapsed: 00:00:00.06
    SQL> commit
      2  /
    Commit complete.
    Elapsed: 00:00:00.00
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Feb 20 22:42:55 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool testcase.log
    SQL> --
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> --
    SQL> -- Testcase code here
    SQL> --
    SQL> set trimspool on
    SQL> set autotrace on explain
    SQL> set timing on
    SQL> set pages 10 lines 160 long 100000
    SQL> --
    SQL> column INVCTLN format  9999
    SQL> column MEDBU   format  A10
    SQL> column TYPE    format  A10
    SQL> column LINECODE format 999999999
    SQL> create or replace view MASTER_TABLE_VIEW
      2  (
      3     INVCTLN,
      4     MEDBU
      5  )
      6  as
      7  select extractValue(value(bill),'/Bill/InvCtlN'),
      8         extractValue(value(bill),'/Bill/MedBU')
      9    from SAMPLE_FILE_TABLE t,
    10         table(xmlsequence(extract(value(t),'/SampleFile/Bill'))) Bill
    11  /
    View created.
    Elapsed: 00:00:00.04
    SQL> create or replace view DETAIL_TABLE_VIEW
      2  (
      3     INVCTLN,
      4     TYPE,
      5     LINECODE
      6  )
      7  as
      8  select extractValue(value(bill),'/Bill/InvCtlN'),
      9         extractValue(value(LineItem),'/Lineitem/Type'),
    10         extractValue(value(LineItem),'/Lineitem/LineCode')
    11    from SAMPLE_FILE_TABLE t,
    12         table(xmlsequence(extract(value(t),'/SampleFile/Bill'))) Bill,
    13         table(xmlsequence(extract(value(bill),'/Bill/Lineitem'))) LineItem
    14  /
    View created.
    Elapsed: 00:00:00.05
    SQL> set autotrace on explain
    SQL> --
    SQL> select * from MASTER_TABLE_VIEW
      2  /
    INVCTLN MEDBU
          1 ABC
          2 DEF
          3 HJK
    Elapsed: 00:00:00.05
    Execution Plan
    Plan hash value: 2362844891
    | Id  | Operation          | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |                    |     3 |  6165 |   805   (1)| 00:00:10 |
    |   1 |  NESTED LOOPS      |                    |     3 |  6165 |   805   (1)| 00:00:10 |
    |*  2 |   TABLE ACCESS FULL| SAMPLE_FILE_TABLE  |     1 |    30 |     3   (0)| 00:00:01 |
    |*  3 |   INDEX RANGE SCAN | SYS_IOT_TOP_159053 |     3 |  6075 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - 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"><rea
                  d-properties/><read-contents/></privilege>'))=1)
       3 - access("NESTED_TABLE_ID"="SAMPLE_FILE_TABLE"."SYS_NC0000800009$")
    Note
       - dynamic sampling used for this statement
    SQL> select * from DETAIL_TABLE_VIEW
      2  /
    INVCTLN TYPE         LINECODE
          1 P1              99214
          3 P4              99217
          2 P2              99215
          2 P3              99216
    Elapsed: 00:00:00.07
    Execution Plan
    Plan hash value: 971642473
    | Id  | Operation               | Name               | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |                    |     4 |  8352 |   813   (0)| 00:00:10 |
    |   1 |  NESTED LOOPS           |                    |     4 |  8352 |   813   (0)| 00:00:10 |
    |   2 |   MERGE JOIN CARTESIAN  |                    |     4 |  8220 |   805   (0)| 00:00:10 |
    |*  3 |    TABLE ACCESS FULL    | SAMPLE_FILE_TABLE  |     1 |    30 |     3   (0)| 00:00:01 |
    |   4 |    BUFFER SORT          |                    |     4 |  8100 |   802   (0)| 00:00:10 |
    |   5 |     INDEX FAST FULL SCAN| SYS_IOT_TOP_159055 |     4 |  8100 |   802   (0)| 00:00:10 |
    |*  6 |   INDEX UNIQUE SCAN     | SYS_IOT_TOP_159053 |     1 |    33 |     2   (0)| 00:00:01 |
    |*  7 |    INDEX RANGE SCAN     | SYS_C0022871       |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - 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-pro
                  perties/><read-contents/></privilege>'))=1)
       6 - access("NESTED_TABLE_ID"="SYS_NTh/v83GzKQ1evte63P5QRog=="."SYS_NC0000700008$")
           filter("NESTED_TABLE_ID"="SAMPLE_FILE_TABLE"."SYS_NC0000800009$")
       7 - access("NESTED_TABLE_ID"="SYS_NTh/v83GzKQ1evte63P5QRog=="."SYS_NC0000700008$")
    Note
       - dynamic sampling used for this statement
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    C:\xdb\otn\362337>

  • Creating XML from Relational Tables using java

    I would like to create an XML document by querying relational tables in java
    try {
            connection = getConnection();
            final String qryStr = "select XMLElement( foo, 'bar' ) from dual";
            final OracleXMLQuery qry = new OracleXMLQuery(connection, qryStr);
            final String xmlString = qry.getXMLString();
    I would expect this to give the following result that I get from running the statement in SQL Developer
    select XMLElement( foo, 'bar' ) from dual
    <FOO>bar</FOO>
    Instead I get
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an XML tag name.</ERROR>
    Is this the correct way to go about this?

    Is this the correct way to go about this?
    Not really.
    OracleXMLQuery class is the Java-side implementation of DBMS_XMLQUERY APIs.
    It's mostly designed to generate a canonical XML document out of a SQL query.
    Assuming a query like "SELECT col1, col2 FROM my_table", the resulting XML should appear like this :
    <ROWSET>
      <ROW>
        <COL1>123</COL1>
        <COL2>ABC</COL2>
      </ROW>
      <ROW>
        <COL1>456</COL1>
        <COL2>XYZ</COL2>
      </ROW>
    </ROWSET>
    So in your test, since the resulting column is not aliased (XMLElement), you're actually trying to generate something like this :
    <ROWSET>
      <ROW>
        <XMLELEMENT(FOO,'BAR')>
          <FOO>bar</FOO>
        </XMLELEMENT(FOO,'BAR')>
      </ROW>
    <ROWSET>
    which of course is invalid, hence the error message.
    If you want to generate only <FOO>bar</FOO> as output, just use a regular PreparedStatement with your query and access the document in the ResultSet with the proper getter.

Maybe you are looking for

  • No sound in Flash Player, using Ubuntu 10.04

    As the title says, there is no sound in Flash Player. I have: flashplugin-nonfree-extrasound      0.0.svn2431-3 flashplugin-nonfree                       10.0.45.2ubuntu1 flashplugin-installer I also have gnash, klash, swfdec and some others. Could y

  • Multiple Values in the Return Parameter

    Hi, My application has a decision table , with material group, division fields and has agent as the return parameter. I need to maintain more than 1 user for each material group/division combination? I even tried using return parameter 'agent' as str

  • Serious problem with text variables in table of contents

    I posted this in the regular InDesign forum -- seems that there's no easy solution that would work well in a production environment (only suggestion was to convert the variables to text). However, thought I'd post it here to see if anyone on the scri

  • SSAS cube role members magically disappear overnight

    Hello, We are running SQL Server 2008 SP1 CU4 and I have been experiencing an occasional issue whereby our cube role members disappear - resulting in the user-dashboards failing on our website, so I am keen to resolve this. Some background: -We have

  • 8330 call forwarding icon won't disappear

    I have a 8330 and I cannot get the call forwarding icon to disappear. Last week I had to forward my number to my office number. I then got a new phone number on this curve. I can make and receive call normally. But the call forwarding icon is still o