Help retreiving XML data in table format

Hello,
i have a field which stores IP and Domain data in XML format. The field data type is BLOB.
here is the XML data sample stored in the field.
<?xml version = '1.0' encoding = 'UTF-8'?>
<DOMAIN Name="DOMAIN_NAME HERE">
<IPADDRESS Address="X.X.X.X1"></IPADDRESS>
<IPADDRESS Address="X.X.X.X2"></IPADDRESS>
<IPADDRESS Address="X.X.X.X3"></IPADDRESS>
<IPADDRESS Address="X.X.X.X4"></IPADDRESS>
... ETC
Is it possible to run SELECT against this field and retrieve the data in the table format, so the output will have two fields and look like
domain IPADDRESS
DOMAIN_NAME HERE X.X.X.X1
DOMAIN_NAME HERE X.X.X.X2
DOMAIN_NAME HERE X.X.X.X3
DOMAIN_NAME HERE X.X.X.X4
I have tried many option with Extract, extractvalue and XMLQuery, not luck.
Thank you very much!
Sergei

Try...
xp20:format-dateTime(string($dateFromDatabase), '[D01]-[MN,*-3]-[Y0001] [H01]:[m01] P')Ref
http://www.w3.org/TR/xslt20/#function-format-dateTime
Cheers,
Vlad

Similar Messages

  • Xml Data into Table Within an Oracle Database

    With no oracle or database background, I have been tasked to figure out how to analyze reading values within xml files. I initially started by writing c# code to read through the xml files, pull out the values I need and summarize the results. Unfortunately, this took atleast 5 hours to open all the xml files and summarize the results for a small portion of EndPointChannelId's and xml files. I decided to store all the reading values within the xml files into a table so I can use SQL queries to do the analysis instead of having to process through all the files each time. Using the same c# code as before, I have used insert and update sql statements to insert the reading values into a table. To my dismay, it takes about 3 and a half hours to import 1 file where there is 20 files a day :S. There are over 19,000 ChannelID's per file. I am currently using SQL Developer to view the data and have noticed XML Schemas and XML DB Repository but am not sure if that would be the best approach to my problem. I need to increase the efficiency of the import process but I am having difficulties trying to figure out how to go about it. Do you have any suggestions on where I should go from here? What is the most efficient way you have used to import xml files into a table structure. I would greatly appreciate any ideas!
    Below is a portion of the xml file that I am working with.
    - <Channel ReadingsInPulse="false" IsRegister="false" IsReadingDecoded="true" MarketType="Electric" IntervalLength="60">
    <ChannelID EndPointChannelID="57432:1" />
    - <ContiguousIntervalSets>
    - <ContiguousIntervalSet NumberOfReadings="6">
    <TimePeriod EndRead="22467.80" EndTime="2013-05-09T13:00:00Z" StartTime="2013-05-09T07:00:00Z" />
    - <Readings>
    <Reading Value="0.31" />
    <Reading Value="0.4" />
    <Reading Value="0.16" />
    <Reading Value="0.32" />
    <Reading Value="0.09" />
    <Reading Value="0.35" />
    </Readings>
    </ContiguousIntervalSet>
    </ContiguousIntervalSets>
    </Channel>

    Hi,
    Welcome to the forums,
    what i understand from your Post, You want to read/analyze some value from xml files. and for this you want to import it in database and then perform some Query on that file for easy work.
    you can choose the External table concept for reading/ Query those files
    check this link may it help you
    Creation of External table by using XML files.
    http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables013.htm

  • Help in XML data..(solved)

    Hi everyone,
    Could someone please help me to solve this..
    I have some XML data in the database in a clob column..like this..
    XMLDATA 1
    ==========
    <findPatientByNameResponse xmlns="http://service.sdt.tact.company.org">
      <out xmlns="http://service.sdt.tact.company.org">
        <ns1:patient xmlns:ns1="http://model.sdt.tact.company.org">
          <age xmlns="http://model.sdt.tact.company.org">66</age>
          <birthDate xmlns="http://model.sdt.tact.company.org">1949-11-23T00:00:00-07:00</birthDate>
          <empi xmlns="http://model.sdt.tact.company.org">544665</empi>
          <firstName xmlns="http://model.sdt.tact.company.org">A</firstName>
          <isValidPatient xmlns="http://model.sdt.tact.company.org">true</isValidPatient>
          <languageCode xmlns="http://model.sdt.tact.company.org">ENGLISH</languageCode>
          <lastName xmlns="http://model.sdt.tact.company.org">SMITH</lastName>
          <maritalStatusCode xmlns="http://model.sdt.tact.company.org">M</maritalStatusCode>
          <middleName xmlns="http://model.sdt.tact.company.org">MADELINE</middleName>
          <newEmpi xmlns="http://model.sdt.tact.company.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <newPatient xmlns="http://model.sdt.tact.company.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <sexCode xmlns="http://model.sdt.tact.company.org">F</sexCode>
        </ns1:patient>
        <ns1:patient xmlns:ns1="http://model.sdt.tact.company.org">
          <age xmlns="http://model.sdt.tact.company.org">47</age>
          <birthDate xmlns="http://model.sdt.tact.company.org">1969-04-15T00:00:00-07:00</birthDate>
          <empi xmlns="http://model.sdt.tact.company.org">540171</empi>
          <firstName xmlns="http://model.sdt.tact.company.org">A</firstName>
          <isValidPatient xmlns="http://model.sdt.tact.company.org">true</isValidPatient>
          <languageCode xmlns="http://model.sdt.tact.company.org">ENGLISH</languageCode>
          <lastName xmlns="http://model.sdt.tact.company.org">SMITH</lastName>
          <maritalStatusCode xmlns="http://model.sdt.tact.company.org">D</maritalStatusCode>
          <middleName xmlns="http://model.sdt.tact.company.org">KELLY</middleName>
          <newEmpi xmlns="http://model.sdt.tact.company.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <newPatient xmlns="http://model.sdt.tact.company.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <sexCode xmlns="http://model.sdt.tact.company.org">F</sexCode>
        </ns1:patient>
      </out>
    </findPatientByNameResponse>I have to parse the above XML...The above XML has 2 records..
    i used the following query to parse the above XML
    QUERY 1
    =======
    select extractValue(value(t),'/birthDate/text()') "birthDate"
         , extractValue(value(t),'/empi') "empi"
         , extractValue(value(t),'/firstName') "firstName"
         , extractValue(value(t),'/lastName') "lastName"
         , extractValue(value(t),'/middleName') "middleName"
         , extractValue(value(t),'/sexCode') "sexCode"
    from nw_test c,
          table(xmlsequence(extract(xmltype.createxml(c.clob_data),'//findPatientByNameResponse/out/patient'))) t
    where c.id = 1;     with the above query ...it is not returing any records....
    and just for a TEST i changed the above XML to some thing more clear
    XML DATA 2 (Just for test)
    ==========
    <findPatientByNameResponse>
      <out>
        <patient>
          <age>63</age>
          <birthDate>1949-11-23T00:00:00-07:00</birthDate>
          <empi>5446</empi>
          <firstName>A</firstName>
          <isValidPatient>true</isValidPatient>
          <languageCode>ENGLISH</languageCode>
          <lastName>SMITH</lastName>
          <maritalStatusCode>M</maritalStatusCode>
          <middleName>MADELINE</middleName>
          <newEmpi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <newPatient xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <sexCode>F</sexCode>
        </patient>
        <patient>
          <age>47</age>
          <birthDate>1967-04-15T00:00:00-07:00</birthDate>
          <empi>540171</empi>
          <firstName>A</firstName>
          <isValidPatient>true</isValidPatient>
          <languageCode>ENGLISH</languageCode>
          <lastName>SMITH</lastName>
          <maritalStatusCode>D</maritalStatusCode>
          <middleName>KELLY</middleName>
          <newEmpi xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <newPatient xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
          <sexCode>F</sexCode>
        </patient>
      </out>
    </findPatientByNameResponse>
    QUERY 2
    =======
    select extractvalue(value(d),'/patient/age') as age,
        extractvalue(value(d),'/patient/birthDate') as birthddate,
        extractvalue(value(d),'/patient/empi') as empi,
        extractvalue(value(d),'/patient/firstName') as firstName,
        extractvalue(value(d),'/patient/languageCode') as languageCode,
        extractvalue(value(d),'/patient/isValidPatient') as isValidPatient,
        extractvalue(value(d),'/patient/lastName') as lastName,
        extractvalue(value(d),'/patient/middleName') as middleName
        from nw_test x,table(xmlsequence(extract(xmltype.createxml(x.clob_data), '/findPatientByNameResponse/out/patient'))) d where id = 2;with query 2 i am able to get the following output
    Age Birthdate empi firstname languagecode isvalidpatient lastname
    Got 2 records...
    Query 2 is working fine..If the change the original XML data..
    But actually i have to parse XML DATA 1
    Could someone please help me with QRERY 1 to parse XMLDATA1.
    Thanks in advance
    phani

    THose namespaces are really a pain. You should consider to have all "xmlns=" removed that are not really needed.
    SQL> r
      1  with x as (select xmltype('<findPatientByNameResponse xmlns="http://service.adt.tactical.intermountain.org"> '
      2                 ||' <out xmlns="http://service.adt.tactical.intermountain.org">'
      3          ||'    <ns1:patient xmlns:ns1="http://model.adt.tactical.intermountain.org">'
      4          ||'      <age xmlns="http://model.adt.tactical.intermountain.org">66</age>'
      5          ||'      <birthDate xmlns="http://model.adt.tactical.intermountain.org">1949-11-23T00:00:00-07:00</birthDate>'
      6          ||'      <empi xmlns="http://model.adt.tactical.intermountain.org">544665</empi>'
      7          ||'      <firstName xmlns="http://model.adt.tactical.intermountain.org">A</firstName>'
      8          ||'      <isValidPatient xmlns="http://model.adt.tactical.intermountain.org">true</isValidPatient>'
      9          ||'      <languageCode xmlns="http://model.adt.tactical.intermountain.org">ENGLISH</languageCode>'
    10          ||'      <lastName xmlns="http://model.adt.tactical.intermountain.org">SMITH</lastName>'
    11          ||'      <maritalStatusCode xmlns="http://model.adt.tactical.intermountain.org">M</maritalStatusCode>'
    12          ||'      <middleName xmlns="http://model.adt.tactical.intermountain.org">MADELINE</middleName>'
    13          ||'      <newEmpi xmlns="http://model.adt.tactical.intermountain.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>'
    14          ||'      <newPatient xmlns="http://model.adt.tactical.intermountain.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>'
    15          ||'      <sexCode xmlns="http://model.adt.tactical.intermountain.org">F</sexCode>'
    16          ||'    </ns1:patient>'
    17          ||'    <ns1:patient xmlns:ns1="http://model.adt.tactical.intermountain.org">'
    18          ||'      <age xmlns="http://model.adt.tactical.intermountain.org">47</age>'
    19          ||'      <birthDate xmlns="http://model.adt.tactical.intermountain.org">1969-04-15T00:00:00-07:00</birthDate>'
    20          ||'      <empi xmlns="http://model.adt.tactical.intermountain.org">540171</empi>'
    21          ||'      <firstName xmlns="http://model.adt.tactical.intermountain.org">A</firstName>'
    22          ||'      <isValidPatient xmlns="http://model.adt.tactical.intermountain.org">true</isValidPatient>'
    23          ||'      <languageCode xmlns="http://model.adt.tactical.intermountain.org">ENGLISH</languageCode>'
    24          ||'      <lastName xmlns="http://model.adt.tactical.intermountain.org">SMITH</lastName>'
    25          ||'      <maritalStatusCode xmlns="http://model.adt.tactical.intermountain.org">D</maritalStatusCode>'
    26          ||'      <middleName xmlns="http://model.adt.tactical.intermountain.org">KELLY</middleName>'
    27          ||'      <newEmpi xmlns="http://model.adt.tactical.intermountain.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>'
    28          ||'      <newPatient xmlns="http://model.adt.tactical.intermountain.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>'
    29          ||'      <sexCode xmlns="http://model.adt.tactical.intermountain.org">F</sexCode>'
    30          ||'    </ns1:patient>'
    31          ||'  </out></findPatientByNameResponse>') myXmlCol
    32          from dual)
    33  select --t.column_value.getClobval(),
    34      extractValue(t.column_value,'//birthDate','xmlns="http://model.adt.tactical.intermountain.org"') "birthDate"
    35  from x x1,
    36*   table(xmlsequence(extract(x1.myXmlcol,'/findPatientByNameResponse/out/ns1:patient','xmlns="http://service.adt.tactical.intermountain.org" xmlns:ns1="http://model.adt.tactical.intermountain.org"'))) t
    birthDate
    1949-11-23T00:00:00-07:00
    1969-04-15T00:00:00-07:00
    SQL> Message was edited by: copy&pasted removed some important code. Added this manually.
    Sven W.

  • Loading this xml data into tables

    Hello,
    I am having a problem loading this XML file into tables. The xml file structure is
    <FILE>
    <ACCESSION>
    some ids
    <INSTANCE>
    some data
    <VARIATION
    </VARIATION>
    <VARIATION>
    </VARIATION> variation gets repeated a number of times
    <ASSEMBLY>
    </ASSEMBLY>
    <ASSEMBLY>
    </ASSEMBLY> Assembly gets repeated a number of times.
    </INSTANCE>
    </ACCESSION>
    </FILE>
    I created a table which has the structure:
    create table accession(
    accession_id varchar2(20),
    Instance instance_type);
    create or replace type instance_type as object
    (method varchar2(20),
    class varchar2(20),
    source varchar2(20),
    num_char number(10),
    variation variation_type,
    assembly assembly_type)
    create or replace type variation_type as object
    (value varchar2(2),
    count number(10),
    frequency number(10),
    pop_id varchar2(10)
    Created a similiar type for assembly.
    When I load it, I could only store the first variation data but not the subsequent ones. Similarly for assembly I could only store the first data but not the subsequent ones.
    Could anyone let me know how I could store this data into tables? I have also included a sample XML file in this message.
    Thank You for your help.
    Rama.
    Here is the sample xml file.
    <?xml version="1.0" ?>
    - <FILE>
    - <ACCESSION>
    <ACCESSION_ID>accid1</ACCESSION_ID>
    - <INSTANCE>
    <METHOD>method1</METHOD>
    <CLASS>class1</CLASS>
    <SOURCE>source1</SOURCE>
    <NUM_CHAR>40</NUM_CHAR>
    - <VARIATION>
    <VALUE>G</VALUE>
    <COUNT>5</COUNT>
    <FREQUENCY>66</FREQUENCY>
    <POP1>pop1</POP1>
    <POP2>pop1</POP2>
    </VARIATION>
    <VARIATION>
    <VALUE>C</VALUE>
    <COUNT>2</COUNT>
    <FREQUENCY>33</FREQUENCY>
    <POP_ID1>pop2</POP_ID1>
    </VARIATION>
    - <ASSEMBLY>
    <ASSEMBLY_ID>1</ASSEMBLY_ID>
    <BEGIN>180</BEGIN>
    <END>180</END>
    <TYPE>2</TYPE>
    <ORI>-</ORI>
    <OFFSET>0</OFFSET>
    </ASSEMBLY>
    - <ASSEMBLY>
    <ASSEMBLY_ID>2</ASSEMBLY_ID>
    <BEGIN>235</BEGIN>
    <END>235</END>
    <TYPE>2</TYPE>
    <ORI>-</ORI>
    <OFFSET>0</OFFSET>
    </ASSEMBLY>
    </INSTANCE>
    </ACCESSION>
    </FILE>

    Hello,
    I could figure out how to load this XML file by using cast(multiset(
    So never mind.
    Thank You.
    Rama.

  • How to Dump XML data into table

    Hi All,
    We have one schema on a server.
    We have created the same schema with only table structures on another new server.
    Now we got the data from the original schema as XML files corresponding to each table.
    For Example, we have Employee table created newly on a new server. Now we have the XML file which has Employee data. We have to dump this XML data into new EMPLOYEE table.
    We have to dump these XML files data into corresponding tables.
    How can we achieve this?
    Please help me..
    Thanks in advance

    Look at this example:
    Assume you have the following XML in a tempxml table (tempxml could be an external table):
    create table tempxml (xml xmltype);
    insert into tempxml values (xmltype(
    '<?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7369</EMPNO>
      <ENAME>SMITH</ENAME>
      <JOB>CLERK</JOB>
      <MGR>7902</MGR>
      <HIREDATE>17-DEC-80</HIREDATE>
      <SAL>800</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7499</EMPNO>
      <ENAME>ALLEN</ENAME>
      <JOB>SALESMAN</JOB>
      <MGR>7698</MGR>
      <HIREDATE>20-FEB-81</HIREDATE>
      <SAL>1600</SAL>
      <COMM>300</COMM>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7521</EMPNO>
      <ENAME>WARD</ENAME>
      <JOB>SALESMAN</JOB>
      <MGR>7698</MGR>
      <HIREDATE>22-FEB-81</HIREDATE>
      <SAL>1250</SAL>
      <COMM>500</COMM>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7566</EMPNO>
      <ENAME>JONES</ENAME>
      <JOB>MANAGER</JOB>
      <MGR>7839</MGR>
      <HIREDATE>02-APR-81</HIREDATE>
      <SAL>2975</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7654</EMPNO>
      <ENAME>MARTIN</ENAME>
      <JOB>SALESMAN</JOB>
      <MGR>7698</MGR>
      <HIREDATE>28-SEP-81</HIREDATE>
      <SAL>1250</SAL>
      <COMM>1400</COMM>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7698</EMPNO>
      <ENAME>BLAKE</ENAME>
      <JOB>MANAGER</JOB>
      <MGR>7839</MGR>
      <HIREDATE>01-MAY-81</HIREDATE>
      <SAL>2850</SAL>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7782</EMPNO>
      <ENAME>CLARK</ENAME>
      <JOB>MANAGER</JOB>
      <MGR>7839</MGR>
      <HIREDATE>09-JUN-81</HIREDATE>
      <SAL>2450</SAL>
      <DEPTNO>10</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7788</EMPNO>
      <ENAME>SCOTT</ENAME>
      <JOB>ANALYST</JOB>
      <MGR>7566</MGR>
      <HIREDATE>19-APR-87</HIREDATE>
      <SAL>3000</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7839</EMPNO>
      <ENAME>KING</ENAME>
      <JOB>PRESIDENT</JOB>
      <HIREDATE>17-NOV-81</HIREDATE>
      <SAL>5000</SAL>
      <DEPTNO>10</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7844</EMPNO>
      <ENAME>TURNER</ENAME>
      <JOB>SALESMAN</JOB>
      <MGR>7698</MGR>
      <HIREDATE>08-SEP-81</HIREDATE>
      <SAL>1500</SAL>
      <COMM>0</COMM>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7876</EMPNO>
      <ENAME>ADAMS</ENAME>
      <JOB>CLERK</JOB>
      <MGR>7788</MGR>
      <HIREDATE>23-MAY-87</HIREDATE>
      <SAL>1100</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7900</EMPNO>
      <ENAME>JAMES</ENAME>
      <JOB>CLERK</JOB>
      <MGR>7698</MGR>
      <HIREDATE>03-DEC-81</HIREDATE>
      <SAL>950</SAL>
      <DEPTNO>30</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7902</EMPNO>
      <ENAME>FORD</ENAME>
      <JOB>ANALYST</JOB>
      <MGR>7566</MGR>
      <HIREDATE>03-DEC-81</HIREDATE>
      <SAL>3000</SAL>
      <DEPTNO>20</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7934</EMPNO>
      <ENAME>MILLER</ENAME>
      <JOB>CLERK</JOB>
      <MGR>7782</MGR>
      <HIREDATE>23-JAN-82</HIREDATE>
      <SAL>1300</SAL>
      <DEPTNO>10</DEPTNO>
    </ROW>
    </ROWSET>'));You can insert into an empty EMP2 table this way:
    SQL> insert into emp2
      2  select myemp.empno, myemp.ename, myemp.job, myemp.mgr,
      3         to_date(myemp.hiredate,'dd-mon-yy'), myemp.sal,
      4         myemp.comm, myemp.deptno
      5  from tempxml x, xmltable('/ROWSET/ROW'
      6                           PASSING x.xml
      7                           COLUMNS
      8                             empno number PATH '/ROW/EMPNO',
      9                             ename varchar2(10) PATH '/ROW/ENAME',
    10                             job   varchar2(9) PATH '/ROW/JOB',
    11                             mgr   number PATH '/ROW/MGR',
    12                             hiredate varchar2(9) PATH '/ROW/HIREDATE',
    13                             sal    number PATH '/ROW/SAL',
    14                             comm   number PATH '/ROW/COMM',
    15                             deptno number PATH '/ROW/DEPTNO'
    16                            ) myemp;
    14 rows created.
    SQL> select * from emp2;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.Max
    http://oracleitalia.wordpress.com

  • Store XML data in tables

    Hi,
    I Have to write a procedure which takes XML data and inserts into some tables.
    If the XML format is fixed then i can use extract function for parsing and can insert into the tables.
    But the problem is there is not fixed format for the xml.
    Are there any built in packages which takes the xml data for parsing..
    Can you please suggest me in this case.
    Thanks,
    Vinod

    >
    Hi vinod,
    I Have to write a procedure which takes XML data and inserts into some tables.
    If the XML format is fixed then i can use extract function for parsing and can insert into the tables.
    But the problem is there is not fixed format for the xml.
    Are there any built in packages which takes the xml data for parsing..You'll have to do a bit of reading. I would recommend you start here
    http://docs.oracle.com/cd/B10500_01/appdev.920/a96621/adx20ppl.htm (if all else fails, read the docco! ;) )
    http://www.oracle-base.com/articles/9i/parse-xml-documents-9i.php
    http://www.quovera.com/whitepapers/downloads/xml_oracle.pdf
    http://anononxml.blogspot.ie/2010/12/methods-to-parse-xml-per-oracle-version.html
    http://www.orafaq.com/wiki/XML
    orafaq and oracle-base are good overall Oracle sites.
    You might also want to look [url http://forums.oracle.com/forums/forum.jspa?forumID=34]here - the XML DB forum.
    HTH,
    Paul...
    Vinod

  • HELP RETRIVEING XML DATA

    Hello,
    i have a field which stores IP and Domain data in XML format. The field data type is BLOB.
    here is the XML data sample stored in the field.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <DOMAIN Name="DOMAIN_NAME HERE">
    <IPADDRESS Address="X.X.X.X1"></IPADDRESS>
    <IPADDRESS Address="X.X.X.X2"></IPADDRESS>
    <IPADDRESS Address="X.X.X.X3"></IPADDRESS>
    <IPADDRESS Address="X.X.X.X4"></IPADDRESS>
    ... ETC
    Is it possible to run SELECT against this field and retrieve the data in the table format, so the output will have two fields and look like
    domain IPADDRESS
    DOMAIN_NAME HERE X.X.X.X1
    DOMAIN_NAME HERE X.X.X.X2
    DOMAIN_NAME HERE X.X.X.X3
    DOMAIN_NAME HERE X.X.X.X4
    I have tried many option with Extract, extractvalue and XMLQuery, not luck.
    Thank you very much!
    Sergei

    Use the extractValue() function to extract the node values.
    Refer example 4-3.
    http://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96620/xdb04cre.htm#1024805

  • Load xml data into table

    Hi all,
    I have an XML file (emp.xml) with below data:
    - <root>
    - <row>
    <lastname>steve</lastname>
    <Age>30</Age>
    </row>
    - <row>
    <lastname>Paul</lastname>
    <Age>26</Age>
    </row>
    </root>
    I'd like to create a stored procedure to store the xml data into EMP table.
    EMP
    LastName Age
    Steve 30
    Paul 26
    I tried to look all the related threads in this forum, but couldn't find the right thread. Any help is greatly appreciated. Thanks

    With
    SQL>  select * from xmltable('root/row' passing xmltype('<root>
    <row>
    <lastname>steve</lastname>
    <Age>30</Age>
    </row>
    <row>
    <lastname>Paul</lastname>
    <Age>26</Age>
    </row>
    </root>') columns lastname path 'lastname',
                       Age path 'Age')
    LASTNAME   AGE      
    steve      30       
    Paul       26   you can now simple do a
    insert into emp as select ....

  • How to Store an XML Data into Table?

    Hi All,
    My Requirement is "I Have an XML File (or) XML Data as CLOB, now I should decode this XML Data and find the equivalent data for columns in a table and then store that in a relational table",
    Would be greatful if any one can provide me a feasible solution (or) good link where I can get this information with examples.
    Thanks in advance,
    Sunil N

    Or,
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.03
    satyaki>
    satyaki>
    satyaki>drop table dump_tab;
    Table dropped.
    Elapsed: 00:00:01.08
    satyaki>
    satyaki>create table dump_tab
      2   (
      3      raw_xml  clob
      4   );
    Table created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>desc dump_tab;
    Name                                      Null?    Type
    RAW_XML                                            CLOB
    satyaki>
    satyaki>
    satyaki>insert into dump_tab
      2  select yy.rxml
      3  from (
      4        select ('  <data>
      5           <var name="document">
      6           <string>Sales Order</string>
      7           </var>
      8           <var name="results">
      9           <recordset rowcount="2">
    10           <field name="sales_num">
    11           <string>12345</string>
    12           <string>60192</string>
    13           </field>
    14           <field name="ord_qty">
    15           <string>10</string>
    16           <string>50</string>
    17           </field>
    18           </recordset>
    19           </var>
    20           </data>'
    21      ) rxml from dual
    22     ) yy;
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>create table results
      2    (
      3      serial_no    number(5),
      4      sales_num    number(7),
      5      ord_qty      number(10)
      6    );
    Table created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>desc results;
    Name                                      Null?    Type
    SERIAL_NO                                          NUMBER(5)
    SALES_NUM                                          NUMBER(7)
    ORD_QTY                                            NUMBER(10)
    satyaki>
    satyaki>select * from dump_tab;
    RAW_XML
      <data>
             <var name="document">
             <string>Sales Order</string>
             </var>
             <var name="results">
             <recordset rowcount="2">
             <field name="sales_num">
             <string>12345</string>
             <string>60192</string>
             </field>
             <field name="ord_qty">
    RAW_XML
             <string>10</string>
             <string>50</string>
             </field>
             </recordset>
             </var>
             </data>
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  insert into results(serial_no,sales_num,ord_qty)
      2  with t
      3    as (
      4         select xmltype(raw_xml) xml from dump_tab
      5       ),
      6    t1 as (select rownum rn, t1.column_value.extract('*/text()') sales_num from t t, table(xmlsequence(t.xml.extract('//field[@name="sales_num"]/string'))) t1),
      7    t2 as (select rownum rn, t2.column_value.extract('*/text()') ord_qty   from t t, table(xmlsequence(t.xml.extract('//field[@name="ord_qty"]/string'))) t2)
      8    select t1.rn x,
      9           to_number(regexp_replace(xmlelement("e",sales_num).getstringval(),'<(|/)e>','')) sales_num
    10           to_number(regexp_replace(xmlelement("d",ord_qty).getstringval(),'<(|/)d>','')) ord_qty
    11      from t1,t2
    12*    where t1.rn = t2.rn
    satyaki>/
    2 rows created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>select * from results;
    SERIAL_NO  SALES_NUM    ORD_QTY
             1      12345         10
             2      60192         50
    Elapsed: 00:00:00.00
    satyaki>Regards.
    Satyaki De.

  • Change PaymentAmountText value in XML Data file of Format Payment Instructr

    How to change the value of PaymentAmountText in XML file generated during of IBY_FD_PAYMENT_FORMAT module: Format Payment Instructions?? This XML Data file is being used by the Check Print rtf template.
    The checks will be used for a Singapore$ (S$) Bank account and USD$ Bank account.
    For the S$ check in XML data file :
    <PaymentAmountText>Eighty-Five Dollars And Sixty***********************</PaymentAmountText> for S$85.60
    For the USD$ check in XML data file:
    <PaymentAmountText>Eighty-Five Dollars And Sixty Cents***********************</PaymentAmountText> for USD$85.60
    I have to add 'cents' for the value of the S$ check.
    It looks to me that since it shows for USD and not for SGD, that one can change this in some kind of set up issue. But where and how?? Or can I manipulate this value in the rtf template too??
    Edited by: user1596364 on 24-mei-2012 8:54

    I have solved my problem in following way.
    For example, I would like 'POUNDS' instead of 'DOLLARS'. Currently my check reads 1000 Dollars and 50 cents. It should read 1000 Pounds and 50 pennies
    You need to change the verbiage in the options field for the payment format. (This is the explanation for GUI users.)
    Copy your Format Payment and add some options to it to make the verbiage read Pounds and pennies. Then create a new Payment Format that uses this new Format Payment. Then put this new Payment Format on the Bank Payment Document for the bank account that needs to pay in Irish Pounds.
    1. Define a new Payment Program under System Administrator.
    Navigate to Concurrent -> Program -> Define
    Query up the Evergreen payment program you are using (ex. APXPBFEG).
    2. Click on the 'Copy to' button.
    Enter a value in the 'Program' field type, for example, "Irish Pounds Program".
    Enter a value in the 'Short name' field type, for example, "APXPBIPP".
    3. Edit the Options field in the Executable zone (Do not click the 'Parameters' button.) In the 'Options' field, enter the following 4 options on one line with one blank space between each option:
    P_UNIT_SINGULAR="Pound"
    P_UNIT_PLURAL="Pounds"
    P_SUB_UNIT_SINGULAR="penny"
    P_SUB_UNIT_PLURAL="pennies"
    (For other currencies, replace "Pound" with "Lira", "Peso",etc.)

  • Extracting date from table, format problems

    Hi
    I am working on scm side, where i need to get the creation date of material from table /sapapo/matkey  .
    The problem is the field has a time stamp .
    intially i was using fm : CONVERSION_EXIT_TSTLC_OUTPUT
    to get the date , but the problem is this fm is not correct , as it depends upon the user date format , and gets date from display
    of the table rather than the server . This is giving me an error
    as the date format can be different everytime , it can be yyyymmdd   or yyyyddmm.
    Which is the way of firstly getting creation date from the time stamp , and in the format stored by databse.

    Hi thanks for ur replies.
    My exact requirement is , that i need to pass the  to a bapi which takes the date in the format  : yyyymmdd.
    So finally whatever be the user date format  , i should use the time stamp and get  the date , in one standard format always.
    It can either be yyyymmdd or YYYYddmm , so that i can set the input for bapi accordingly.

  • Help needed XML to Internal table and vice versa

    Hello frnds, I need to convert Internal table to XML and Vice versa.
    Now I am able to most of the part except for this...
    the xml which I have to generate looks something like this...
    - <trade_dt>
    - <![CDATA[ 20111108000000:20111108235959
      ]]>
      </trade_dt>
    its a range I think
    And then the reponse which I get back the XML is like
    - <lockinfo>
    - <![CDATA[
    TRD_HEADER     1045     1          2
    ACT_CASHFLOW     1042               1
    TRD_TERM     1045               2
      ]]>
      </lockinfo>
    Is there any provision in class cl_ixml or class if_ixml_element to handle this part.....
    Edited by: Amit Sawant on Dec 28, 2011 3:51 PM

    Hello Amit,
    I would suggest you, to use the XSL-Transformations, which can be inbound used in ABAP.
    For example:
    DATA:
      l_xml       TYPE string,
      lt_flights  TYPE TABLE OF SFLIGHT.
    SELECT * FROM SFLIGHT INTO TABLE LT_FLIGHT.
    CALL TRANSFORMATION id
      SOURCE DATA = lt_flights
      RESULT XML l_xml.
    Now, you have a XML-String which is in the ABAP-XML Notation, which means, that ABAP can move this XML-Data back into an internal table/structure.
    For the backward, you have to use the following statement:
    CALL TRANSFORMATION id
      SOURCE XML l_xml
      RESULT DATA = lt_flights.
    As you will see, it is very easy. The Transformation "id" is just one example and build in. When you have to transform the data, or do not want to have the ASX-Notation in it, you should at least define your own transformations with the transaction XSLT_TOOL and use it similar to the transformation "id".
    Kind Regards,
    Hendrik

  • XML Data into table

    Hello
    Sorry, for the next question, but it doens't wort :-(...
    I want to insert this xmldata into a table:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
    <aps:Operations xmlns:aps="Software" aps_version="V4.02-03.00" aps_versionl="4020300">
    <Event>
    <name>Dispatcher</name>
    <dtsysl>20110428</dtsysl>
    <hrsysl>95835</hrsysl>
    <dtcptl>20110428</dtcptl>
    <nusesi>1</nusesi>
    <DSP>
    <step>WAIT</step>
    <state>Start</state>
    </DSP>
    </Event>
    </aps:Operations>
    CREATE OR REPLACE DIRECTORY test_dir AS '/oracle/temp/';
    CREATE TABLE test_xml
    (name VARCHAR (40),
    dtsysl DATE,
    hrsysl NUMBER,
    dtcptl DATE,
    nusesi NUMBER,
    step VARCHAR (40),
    state VARCHAR (40) );
    INSERTINTO test_xml (name, dtsysl,hrsysl,dtcptl,nusesi,step,state)
    SELECT *
    FROM XMLTABLE (
    '/ROWSET/ROW'
    PASSING xmltype (BFILENAME (TEST_DIR', 'test.xml'), NLS_CHARSET_ID ('CHAR_CS'))
    COLUMNS name VARCHAR (40) path 'name',
    dtsysl DATE path 'dtsysl',
    hrsysl NUMBER path 'hrsysl',
    dtcptl DATE path 'dtcptl',
    nusesi NUMBER path 'nusesi',
    step VARCHAR (40) path 'step',
    state VARCHAR (40) path 'state');
    The message is always "0 rows inserted".
    Thanks for your support.
    roger
    Edited by: Street on 28.04.2011 04:31
    Edited by: Street on 28.04.2011 04:36

    Apparently, you're using sample code from another example?
    The problem is the use of "/ROWSET/ROW", there's no such path in the XML document, hence XMLTable returning nothing.
    In your case the correct query would be :
    SELECT *
    FROM XMLTABLE (
      XMLNamespaces('Software' as "aps"),
      '/aps:Operations/Event'
      PASSING xmltype (BFILENAME ('TEST_DIR', 'test.xml'), NLS_CHARSET_ID ('CHAR_CS'))
      COLUMNS name   VARCHAR (40) path 'name',
              dtsysl DATE         path 'dtsysl',
              hrsysl NUMBER       path 'hrsysl',
              dtcptl DATE         path 'dtcptl',
              nusesi NUMBER       path 'nusesi',
              step   VARCHAR (40) path 'DSP/step',
              state  VARCHAR (40) path 'DSP/state'
    );See the XQuery expression "/aps:Operations/Event", it represents the access path of the element you consider as the record of data.
    Hope that helps.

  • Need help in XML data processing

    Hi All,
    I have to process a stored procedure's input parameter which comes as a string in the XML format.
    Ex:
    <Search>
    <Row1>
    <Table1>Tab1</Table1>
    <Column1>col1</Column1>
    <Operator1>op1</Operator1>
    <Value1>val1</Value1>
    </Row1>
    <Row2>
    <Table2>Tab2</Table2>
    <Column2>col2</Column2>
    <Operator2>op2</Operator2>
    <Value2>val2</Value2>
    </Row2>
    </search>
    I should process the above parameter and build a select query from each row.
    Ex: select * from Tab1 where col1 op1 val1;
    How can i achieve this?
    i am using oracle 11g version.
    Thanks in advance to all.

    Your xml is not "well-formed" as every tag has a separate name (the numbering part in Row1, Row2 etc.), i would expect it as
    <Search>
      <Row>
        <Table>Tab1</Table>
        <Column>col1</Column>
        <Operator>op1</Operator>
        <Value>val1</Value>
      </Row>
      <Row>
        <Table>Tab2</Table>
        <Column>col2</Column>
        <Operator>op2</Operator>
        <Value>val2</Value>
      </Row>
    </Search>Anyway, this would do what you want:
    WITH DATA AS (SELECT XMLTYPE('<Search>
                                  <Row1>
                                  <Table1>Tab1</Table1>
                                  <Column1>col1</Column1>
                                  <Operator1>op1</Operator1>
                                  <Value1>val1</Value1>
                                  </Row1>
                                  <Row2>
                                  <Table2>Tab2</Table2>
                                  <Column2>col2</Column2>
                                  <Operator2>op2</Operator2>
                                  <Value2>val2</Value2>
                                  </Row2>
                                  </Search>') xml
                    FROM DUAL
    SELECT 'SELECT * FROM ' || TAB || ' WHERE ' ||COL || ' ' || OPER || ' ' || VALUE
      FROM (SELECT EXTRACTVALUE(xml, '/Search/Row' || LEVEL || '/Table' || LEVEL) TAB,
                   EXTRACTVALUE(xml, '/Search/Row' || LEVEL || '/Column' || LEVEL) COL,
                   EXTRACTVALUE(xml, '/Search/Row' || LEVEL || '/Operator' || LEVEL) OPER,
                   EXTRACTVALUE(xml, '/Search/Row' || LEVEL || '/Value' || LEVEL) VALUE
              FROM DATA
              CONNECT BY LEVEL<100
    WHERE TAB IS NOT NULL

  • Alligning data in table format

    I have a SQL view that contains a Land Plot Number, Person id's along with their details and any associated land Interests, which can be 1 or many and Interest Type boolean field(Freehold, Leasehold, Occupier). If the person is associated with more than one piece of land the view contains repeated person details with new land details. I have designed the report to look like a table by using boxes which span the page header to a group footer. The report is grouped by the Plot Number, I have created 3 formulaes that check for the type of interest and concat the address detail, and inserted them into the detail line. The report works OK the only problem I have is that I need to show the information in the following format (Alligned to top): -
    ID   Address Type 1    Address Type 2    Address Type 3
    1    XXXXXXXX           XXXXXXXX          XXXXXXXX
         XXXXXXXX           XXXXXXXX          XXXXXXXX
         XXXXXXXX           XXXXXXXX          XXXXXXXX
         XXXXXXXX           XXXXXXXX          XXXXXXXX
    2    XXXXXXXX           XXXXXXXX          XXXXXXXX
         XXXXXXXX           XXXXXXXX          XXXXXXXX
         XXXXXXXX           XXXXXXXX          XXXXXXXX
         XXXXXXXX           XXXXXXXX          XXXXXXXX
                                              XXXXXXXX
                                              XXXXXXXX
                                              XXXXXXXX
                                              XXXXXXXX
    AND NOT AS IT CURRENTLY RETURNS (Gaps): -
    ID   Address Type 1    Address Type 2    Address Type 3
    1    XXXXXXXX        
         XXXXXXXX          
         XXXXXXXX         
         XXXXXXXX          
                           XXXXXXXX        XXXXXXXX
                           XXXXXXXX        XXXXXXXX
                           XXXXXXXX        XXXXXXXX
                           XXXXXXXX        XXXXXXXX
    2   XXXXXXXX                                      
        XXXXXXXX                                      
        XXXXXXXX                                      
        XXXXXXXX                                                                               
    XXXXXXXX
                                           XXXXXXXX
                                           XXXXXXXX
                                           XXXXXXXX
                          XXXXXXXX         XXXXXXXX
                          XXXXXXXX         XXXXXXXX
                          XXXXXXXX         XXXXXXXX
                          XXXXXXXX         XXXXXXXX
    Hope this makes sense, any advice would be greatly appreciated.
    Thanks

    It's a bit hard to tell how your report is structured, but it sounds like what you are needing to do can be accomplished by using Multi-column.
    Go to the Section Expert for the Details section - on the common tab, check on "Format with Multiple Columns".  When you do this, a new tab will show up "Layout".  Go to this tab and change the radio button at the bottom for Printing direction to be "Across then down".  Set the size of your columns here and go check your report.  You should be able to tweak this Layout to accomplish what you after.

Maybe you are looking for