Complex transformation inserting xml data to oracle database.

Hi,
I Have one small Problem While loading xml data to a oracle database.
In the XSD i have the Columns Like this.
<Data>
<Type_Trs>
<T1>
<T2>
</Data>
My Database contains only two columns
For Example:
Type_Trs
Corr_Data.
Now My problem is Based on Type_Trs Value i need to take values of T1 and T2 should be loaded in Corr_Data column.
How to write Xsl transformation for this using <xsl:choose>.
For Clearing the Question I am giving the Example.
Case : 1
<Data>
<type_Trs>BO</Type_Trs>
<T1>1</T1>
<T2>2</T2>
</Data>
In the Example my type_trs is value 'BO', so the Data in table should be
Type_Trs Corr_Data
======= =======
BO 1
Case : 2
<Data>
<type_Trs>CP</Type_Trs>
<T1>1</T1>
<T2>2</T2>
</Data>
In the Example my type_trs is value 'CP', so the Data in table should be
Type_Trs Corr_Data
======= =======
CP 2
For doing this How can i write my XSL transformation based on the condition?
Thanks in advances
Regards
GSR

Why do you need a XSL transformation for this? Can you not get the results based on this select:
SQL> SELECT DISTINCT EXTRACTVALUE (t2.COLUMN_VALUE, 'Type_Trs') type_trs,
                CASE EXTRACTVALUE (t2.COLUMN_VALUE, 'Type_Trs')
                   WHEN 'BO'
                      THEN EXTRACTVALUE (t3.COLUMN_VALUE, 'T1')
                   WHEN 'CP'
                      THEN EXTRACTVALUE (t4.COLUMN_VALUE, 'T2')
                END corr_data
           FROM TABLE
                   (XMLSEQUENCE
                       (EXTRACT
                           (XMLTYPE
                               ('<Data>
                      <Type_Trs>BO</Type_Trs>
                      <T1>1</T1>
                      <T2>2</T2>
                      <Type_Trs>CP</Type_Trs>
                      <T1>1</T1>
                      <T2>2</T2>
                    </Data>'
                            '/Data'
                   ) t1,
                TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE,
                                             '/Data/Type_Trs')
                      ) t2,
                TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/Data/T1'))) t3,
                TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/Data/T2'))) t4
TYPE_TRS   CORR_DATA
CP         2        
BO         1        

Similar Messages

  • Steps to insert xml data into oracle

    Please give me next steps to insert xml data into oracle 9i:
    i've been doing this steps :
    1. create folder in oracle port:8080
    2. copy xsd into folder
    3. register schema
    4. Give me next step...
    5.
    6.
    Thanks

    this is my complete xmlschema
    <?xml version = "1.0" encoding = "UTF-8"?>
    <xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
         <xs:element name = "A3A8Vers" type = "xs:string"/>
         <xs:element name = "F1F5Vers" type = "xs:string">
         </xs:element>
         <xs:element name = "sequence" type = "xs:string">
         </xs:element>
         <xs:element name = "amf" type = "xs:string">
         </xs:element>
         <xs:element name = "trnsKeyNumber" type = "xs:string">
         </xs:element>
         <xs:element name = "mac" type = "xs:string">
         </xs:element>
         <xs:element name = "encryptionKey" type = "xs:string">
         </xs:element>
         <xs:element name = "signature" type = "xs:string">
         </xs:element>
         <xs:element name = "signer">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref = "entityNumber"/>
                        <xs:element ref = "keyNumber"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name = "entityNumber" type = "xs:string">
         </xs:element>
         <xs:element name = "keyNumber" type = "xs:string">
         </xs:element>
         <xs:element name = "pblKey">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref = "entityNumber"/>
                        <xs:element ref = "entityRole"/>
                        <xs:element ref = "keyNumber"/>
                        <xs:element ref = "publicKeyVal"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name = "ntrTime" type = "xs:string">
         </xs:element>
         <xs:element name = "deActionTime" type = "xs:string">
         </xs:element>
         <xs:element name = "actionTime" type = "xs:string">
         </xs:element>
         <xs:element name = "entityRole">
              <xs:complexType>
                   <xs:attribute name = "role" default = "INVALID">
                        <xs:simpleType>
                             <xs:restriction base = "xs:NMTOKEN">
                                  <xs:enumeration value = "TKD"/>
                                  <xs:enumeration value = "SKD"/>
                                  <xs:enumeration value = "INVALID"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:attribute>
              </xs:complexType>
         </xs:element>
         <xs:element name = "publicKeyVal">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref = "exponent"/>
                        <xs:element ref = "mod"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name = "exponent" type = "xs:string">
         </xs:element>
         <xs:element name = "mod" type = "xs:string">
         </xs:element>
         <xs:element name = "encriptionTransKey" type = "xs:string">
         </xs:element>
         <xs:element name = "keyType" type = "xs:string">
         </xs:element>
    </xs:schema>.
    I use command to create table :
    create table elements of xmltype
    xmlschema "http://192.168.1.1:8080/test.xsd"
    element "publicKey"
    . But why the result,table as object type. so i cant use command "desc <table_name>;"

  • Insert XML data into oracle table

    I want to insert xml data returned by the VB code into oracle table.
    As a prequisite I have installed the XDK capabilities for Oracle by installing JServer & running
    SQL scripts catxsu.sql,xmlparserv2.jar,load.sql to load the XMLSQL Utility (DBMS_XMLQuery) into the database.
    I have also granted following privileges to the user.
    Grant users access to XMLParser and XMLDom packages:
         grant execute on xmldom to public;
         grant execute on xmlparser to public;
         create public synonym xmldom for sys.xmldom;
         create public synonym xmlparser for sys.xmlparser;
    But still i am not able to create procedure which will accept input parameter as an XML document coming from front end which in turn will insert that record into simple oracle table . I am using Oracle 8.1.7
    Thanks in advance

    Would you specify the database version?
    Since DBMS_XMLSave requires DOM, you normally need to divide the huge XML before insertion.

  • Load xml data to oracle database table

    hi,
    i am facing some problem in fetching from xml data into oracle . That if the table column name and xsl and xsd tag are equal then data is fetching .
    if we we are changing column name in xsl and xsd then data is not fetching.
    the soure is like that
    XSD FILE
    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
         </xs:complexType>
         <xs:complexType name="TRANSAC_Type">
    <xs:all>
    <xs:element name="NECRITUR" type="Char4_Type" minOccurs="0" nillable="false"/>
    <xs:element name="NPTF_INT" type="Char2_Type" minOccurs="0" nillable="false"/>
    </xs:all>
    </xs:complexType>
    <xs:simpleType name="Char1_Type">
    <xs:restriction base="xs:string">
    <xs:maxLength value="1"/>
    </xs:restriction>
    </xs:simpleType>
    XSL FILE
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:output method="xml" indent="yes"/>
    <!-- Treatment of fields for table -->
    <xsl:template match="NECRITUR">
    <NO_ECRIT_INT>
    <xsl:value-of select="."/>
    </NO_ECRIT_INT>
    </xsl:template>
    <xsl:template match="NPTF_INT">
    <NPTF_INT>
    <xsl:value-of select="."/>
    </NPTF_INT>
    </xsl:template>
    </xsl:template>
    </xsl:stylesheet>
    Xml file
    <File xmlns:xsi="http://www.’’’’’ ">
    <Header>
    <FileType>TRANSAC</FileType>
    <FileName>TRANSAC.XML</FileName>
    <CreationDate>2007-02-22</CreationDate>
    <CreationTime>14:56:48</CreationTime>
    </Header>
    <Data>
    <TRANSAC>
    <NECRITUR>6</NECRITUR>
    <NPTF_INT>MMMM</NPTF_INT>
    </TRANSAC>
    </Data>
    </File>
    Table Is
    REP (NO_ECRIT_INT, NPTF_INT, CreationDate, CreationTime)
    Regards
    manu
    Message was edited by:
    user561683

    Hi Manu
    Im not quite sure what your question is?
    Are you trying to load data to the database or
    Are you trying to retrieve data from the database ?
    Either way this forum is meant for XML Publisher or BI Publisher issues not just XSL ... you might be better asking on the XML forum.
    Regards, Tim

  • Parsing xml data into oracle database

    Oracle ACEs,
    We got a requirement that needs to load xml data into oracle db. Is it possible to load xml data into oracle db using built-in package. Is Oracle provides one ?
    Our database version is Oracle 9i.
    Your help in this regard is highly appreciated.
    Many Thanks.

    Check this out.
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_xmlsav.htm#1008593

  • How to validate inserted xml data in oracle is correct or not

    (i.e.how to validate xml syntax and tags are correct)
    XML data has been inserted in Oracle database.Once inserted
    I want to validate that data entered and tags inserted are correct
    or not.
    Pl help

    Some small remarks after a life time of write that small notepad.
    Don't use XMLIsValid() - Apperently it was once ment for use in table constraints only AND the most annoying part, it doesn't give you a proper error message.
    More usable is schemaValidate() - it throws a useful error message... I never came around to update that post or write a proper one while using schemaValidate().
    I would be against advising / using a Java wrapper to achieve this goal unless you are on a pre 9.2 database version. Registering, validation and such is optimized (in memory) in Oracle from the beginning in 9.2.0.3 and onwards to avoid for instance reparsing of the XML Schema itself. If a XML Schema is registered a lot is optimized including DOM, which will be avoided and "outsmarted" by using XOB objects (see the Oracle manuals only a few hits and those will point you directly to the optimizations at hand).

  • Storing xml file (NOT XML DATA) in oracle database

    Hi,
    i want to know if is it possible to store whole xml file (eg: abc.xml) as one variable (CLOB) in one of the columns of a table..
    i dont want the data contained in the abc.xml to be stored in table/database, but the whole abc.xml file, including all the < and > symbols,, basically a text file.
    Thanks,
    RK

    Hi,
    I need to store the data from XML file in table using XML Parser for PL/SQL can anyone please help me out with this my database version is 8.1.7. I even need help on creating XML file using XML Parser for PL/SQL, any help in this regard will be a boon for me.
    Best Regards,
    Vijay Sehgal

  • CMP to insert CLOB Data in Oracle

    I have a CMP which tries to insert CLOB data into Oracle Database using XMLType column. We have tried multiple options
    1. Inserting String data into XMLType column - if the value is more than 4000 chars, it gives an error
    2. Inserting CLOB Data into XMLType column - Using the OracleCLob option in the deployment descriptor results in a SQLExcepotion Inconsistent datatype expected number found CLOB.
    Can anybody provide a solution to this problem?

    I have a CMP which tries to insert CLOB data into Oracle Database using XMLType column. We have tried multiple options
    1. Inserting String data into XMLType column - if the value is more than 4000 chars, it gives an error
    2. Inserting CLOB Data into XMLType column - Using the OracleCLob option in the deployment descriptor results in a SQLExcepotion Inconsistent datatype expected number found CLOB.
    Can anybody provide a solution to this problem?

  • How to insert more than 32k xml data into oracle clob column

    how to insert more than 32k xml data into oracle clob column.
    xml data is coming from java front end
    if we cannot use clob than what are the different options available

    Are you facing any issue with my code?
    String lateral size error will come when you try to insert the full xml in string format.
    public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
      boolean isUpdated = true;
      Connection connection = null;
      try {
      connection = ConnectionManager.getConnection ();
      //connection.setAutoCommit ( false );
      PreparedStatement PREPARE_STATEMENT = null;
      String sqlQuery = "UPDATE " + tableName + " SET " + columnName + "  = ?  WHERE ID =" + id;
      PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
      // converting string to reader stream
      Reader reader = new StringReader ( strContents );
      PREPARE_STATEMENT.setClob ( 1, reader );
      // return false after updating the clob data to DB
      isUpdated = PREPARE_STATEMENT.execute ();
      PREPARE_STATEMENT.close ();
      } catch ( SQLException e ) {
      e.printStackTrace ();
      finally{
      return isUpdated;
    Try this JAVA code.

  • Inserting xml data in a MYSQL database

    Hi,
    I would like to know how i can insert data from an xml file into a MYSQL database using a java program, I currently have a program which retrieves an xml record and i need to insert the information between the tags into a table in MYSQL..please help me out if anyone knows...i am not very familiar with java...thanks

    Hi there Sherkhan,
    Im trying to do exactly what ur doing, inserting xml data in to a mySQL database. Any chance u could share the code for this???
    Many thanks in advance.

  • Extract data from XML file to Oracle database

    Dear All
    Please let me know, how to extract data from XML file to Oracle database which includes texts & images.
    Thanking You
    Regards Lakmal Marasinghe

    I would do it from the database, but then again, I am a database / PL/SQL guy.
    IMHO the database will deliver you with more options. I don't know about "speed" between the two.

  • Best method to load XML data into Oracle

    Hi,
    I have to load XML data into Oracle tables. I tried using different options and have run into a dead end in each of those. I do not have knowledge of java and hence have restricted myself to PL/SQL solutions. I tried the following options.
    1. Using DBMS_XMLSave package : Expects the ROWSET and ROW tags. Connot change format of the incoming XML file (Gives error oracle.xml.sql.OracleXMLSQLException: Start of root element expected).
    2. Using the XMLPARSER and XMLDOM PL/SQL APIs : Works fine for small files. Run into memory problems for large files (Gives error java.lang.OutOfMemoryError). Have tried increasing the JAVA_POOL_SIZE but does not work. I am not sure whether I am changing the correct parameter.
    I have read that the SAX API does not hog memory resources since it does not build the entire DOM tree structure. But the problem is that it does not have a PL/SQL implementation.
    Can anyone PLEASE guide me in the right direction, as to the best way to achieve this through PL/SQL ??? I have not designed the tables so am flexible on using purely relational or object-relational design. Although would prefer to keep a purely relational design. (Had tried used object-relational for 1. and purely relational for 2. above)
    The XML files are in the following format, (EXAMINEEs with single DEMOGRAPHIC and multiple TESTs)
    <?xml version="1.0"?>
    <Root_Element>
    <Examinee>
    <MACode>A</MACode>
    <TestingJID>TN</TestingJID>
    <ExamineeID>100001</ExamineeID>
    <CreateDate>20020221</CreateDate>
    <Demographic>
    <InfoDate>20020221</InfoDate>
    <FirstTime>1</FirstTime>
    <LastName>JANE</LastName>
    <FirstName>DOE</FirstName>
    <MiddleInitial>C</MiddleInitial>
    <LithoNumber>73</LithoNumber>
    <StreetAddress>SomeAddress</StreetAddress>
    <City>SomeCity</City>
    <StateCode>TN</StateCode>
    <ZipCode>37000</ZipCode>
    <PassStatus>1</PassStatus>
    </Demographic>
    <Test>
    <TestDate>20020221</TestDate>
    <TestNbr>1</TestNbr>
    <SrlNbr>13773784</SrlNbr>
    </Test>
    <Test>
    <TestDate>20020221</TestDate>
    <TestNbr>2</TestNbr>
    <SrlNbr>13773784</SrlNbr>
    </Test>
    </Examinee>
    </Root_Element>
    Thanks for the help.

    Please refer to the XSU(XML SQL Utility) or TransX Utility(for Multi-language Document) if you want to load data in XML format into database.
    Both of them require special XML formats, please first refer to the following docs:
    http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/xsu/xsu_userguide.html
    http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/transx/readme.html
    You can use XSLT to transform your document to the required format.
    If you document is large, you can use SAX method to insert data into database. But you need to write the code.
    The following sample may be useful:
    http://otn.oracle.com/tech/xml/xdk_sample/xdksample_040602i.html

  • How to create a Macro in excel to store the excel data to Oracle Database

    Hi All
    Does anyone has created a macro in excel which on being run stores the excel data to Oracle database. In my project I need to create one such macro for updating oracle database with excel data and another for inserting excel records.
    I tried doing this using a macro in MS access but Client wants its to be done using Excel Macro only.
    Any help would be highly appreciated.
    Thanks in advance..
    Shikha

    Please read Chapter 19.7 Creating Selection Lists (http://download.oracle.com/docs/html/B25947_01/web_complex007.htm#CEGFJFED) of the Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g Release 3 (10.1.3.0)
    Cheers,
    Mick.

  • How to export an XML file from oracle database?

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AM

    user3523292 wrote:
    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AMThis is a forum of volunteers. There is no "urgent" here. Nevertheless, a google search of 'xml oracle export' quickly lead me to this Oracle site:
    otn.oracle.com/sample_code/tech/xml/index.html
    I also see lots of hits when I search the documentation library at tahiti.oracle.com for 'xml'. This one in particular may be what you are looking for:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#ADXDK070

  • Export an XML file from oracle database

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database? is it possible..?
    thanks in advance,
    Bala. is it possible?
    Edited by: user3523292 on Nov 14, 2008 5:45 AM

    Here's the quick and dirty method using SQL*Plus...
    SQL> select * from emp where deptno = 10;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    SQL> set markup html on
    SQL&gt; select * from emp where deptno = 10;
    <br>
    <p>
    <table border='1' width='90%' align='center' summary='Script output'>
    <tr>
    <th scope="col">
    EMPNO
    </th>
    <th scope="col">
    ENAME
    </th>
    <th scope="col">
    JOB
    </th>
    <th scope="col">
    MGR
    </th>
    <th scope="col">
    HIREDATE
    </th>
    <th scope="col">
    SAL
    </th>
    <th scope="col">
    COMM
    </th>
    <th scope="col">
    DEPTNO
    </th>
    </tr>
    <tr>
    <td align="right">
          7782
    </td>
    <td>
    CLARK
    </td>
    <td>
    MANAGER
    </td>
    <td align="right">
          7839
    </td>
    <td>
    09-JUN-81
    </td>
    <td align="right">
          2450
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    <tr>
    <td align="right">
          7839
    </td>
    <td>
    KING
    </td>
    <td>
    PRESIDENT
    </td>
    <td align="right">
    </td>
    <td>
    17-NOV-81
    </td>
    <td align="right">
          5000
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    <tr>
    <td align="right">
          7934
    </td>
    <td>
    MILLER
    </td>
    <td>
    CLERK
    </td>
    <td align="right">
          7782
    </td>
    <td>
    23-JAN-82
    </td>
    <td align="right">
          1300
    </td>
    <td align="right">
    </td>
    <td align="right">
            10
    </td>
    </tr>
    </table>
    <p>
    SQL&gt;which you can spool to a file.

Maybe you are looking for

  • Web service and ejp enterprise in JBoss

    Is Java a compiled language? Actually, Java is a compiled/interpreted language. See the links below. This is the best classification for the Java language, in my opinion. Read [_this thread_|http://forums.sun.com/thread.jspa?threadID=5320643&start=0&

  • Problem in transporting workflows

    Hi, There are some workflows already existent in the QA system. I try to make some client specific changes to the workflow template and one of the tasks and after Im done. I try to create a new request to send across the changed wf template and the c

  • WebDynpro ABAP vs WebDynpro JAVA for Adobe forms--PCRs--MSS

    Hi Experts, This might be a generic question : I am modifying PCRs (MSS 1.0,EP 7,ECC 6.0) and now I have come to a point where I need to decide if I have to use Webdynpro JAVA or Webdynpro ABAP for modifying Adobe interactive forms which come with MS

  • Optical out and internal spaeker issue.. i need help..

    how can i get rid of the internal speaker sound without disconnecting it from the board or pluging any 1/8 trs jack at the back while using optical out. need help ...... thanks!!!!

  • Having Issues with Outlook Calender Syncing on a BB Curve on Nextel

    My boss at work recently got the BB Curve from nextel and we have gotten the device setup pretty much the way he wants it. There is a small issue though that when he tries to sync his callender it gets to the same spot, event number 31 throws out a n