Extract data from xml column to other table

Hi
I have a table with clob column, inside have a xml, How can I to extract data inside column
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
PL/SQL Release 9.2.0.8.0 - Production
CORE     9.2.0.8.0     Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production

thank you
I have a table
SQL> desc xml_documents;
Name      Type          Nullable Default Comments
DOCNAME   VARCHAR2(200)                          
XMLDOC    CLOB          Y                        
TIMESTAMP DATE          Y                         inside XMLDOC column there is only a record below
<!-- claim77804.xml -->
<Claim>
<ClaimId>77804</ClaimId>
<Policy>12345</Policy>
<Settlements>
<Payment Approver="JCOX">1000</Payment>
<Payment Approver="PSMITH">1850</Payment>
</Settlements>
<DamageReport>
The insured's <Vehicle Make="Volks">Beetle</Vehicle>
broke through the guard rail and plummeted into a ravine.
The cause was determined to be <Cause>faulty brakes</Cause>.
Amazingly there were no casualties.
</DamageReport>
</Claim>I tried to use example from : http://www.oracle-base.com/articles/9i/xmlsequence.php
SELECT extract(value(d), '//POLICY/text()').getStringVal() AS empno
FROM    xml_documents x,
       table(xmlsequence(extract(x.xmldoc, '/ROWSET/Claim'))) d;But no work, show me error
ORA-00932: inconsistent datatypes: expected - got -

Similar Messages

  • Extract Data from XML and Load into table using SQL*Loader

    Hi All,
    We have a XML file (sample.xml) which contains credit card transaction information. We have a standard SQL*Loader control file which loads the data from a flat file and the control file code is written as position based method. Our requirement is to use this control file as per our requirement(i.e) load the data into the table from our XML file), But we need help in converting the XML to a flat file or Extract the data from the XML tags and pass the information to the control file and in turn it loads the table.
    Your suggestion is highly appreciated.
    Thanks in advance

    Hi,
    First of all go to PSA maintanance ( Where you will see PSA records ).
    Goto list---> Save-> File---> Spreadsheet (Choose Radio Button)
    > Give the proper file name where you want to download and then-----> Generate.
    You will get ur PSA data in Excel Format.
    Thanks
    Mayank

  • Sql to extract data from XML column

    Hi I am able to get the the following data to Apex_collection,
    Can you help me how to transform it to muliple rows for EventNumber,EventDesc columns.
    I have tried with Extractvalue it returns null.
    <?xml version="1.0" encoding="ISO-8859-1"?> <ResultSet><DataRow><EventNumber>3</EventNumber><StartDate>03/10/2007</StartDate><EventDesc>Networking Skills</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>45</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Skills Session</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>AMBA</EventClass></DataRow><DataRow><EventNumber>8</EventNumber><StartDate>10/10/2007</StartDate><EventDesc>Demystifying to IB</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>45</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Workshop</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>AMBA</EventClass></DataRow><DataRow><EventNumber>14</EventNumber><StartDate>16/10/2007</StartDate><EventDesc>Bank of England Grad Presentation</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>40</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Recruitment Presentation</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>AMSC</EventClass></DataRow><DataRow><EventNumber>17</EventNumber><StartDate>17/10/2007</StartDate><EventDesc>Effective use of the alumni network</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>45</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Other</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>N</MultiSession><EventClass>AMBA</EventClass></DataRow><DataRow><EventNumber>18</EventNumber><StartDate>17/10/2007</StartDate><EventDesc>Personal Brand</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>45</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Workshop</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>AMBA</EventClass></DataRow><DataRow><EventNumber>19</EventNumber><StartDate>17/10/2007</StartDate><EventDesc>Speed Reading</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>20</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Workshop</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>AMBA</EventClass></DataRow><DataRow><EventNumber>22</EventNumber><StartDate>18/10/2007</StartDate><EventDesc>Morgan Stanley - Applying to IB</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>30</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Recruitment Presentation</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>MSCFINRISK</EventClass></DataRow><DataRow><EventNumber>27</EventNumber><StartDate>22/10/2007</StartDate><EventDesc>Power &Energy Group</EventDesc><EventReference></EventReference><NumberOfAttendees>0</NumberOfAttendees><MaximumAttendees>30</MaximumAttendees><NumberOnWaitingList>0</NumberOnWaitingList><NumberInterested>0</NumberInterested><SubjectDesc>Recruitment Presentation</SubjectDesc><SkillLevelDesc>Group</SkillLevelDesc><EventStatus>TAKI</EventStatus><VenueDesc>LTG</VenueDesc><Template>N</Template><MultiSession>Y</MultiSession><EventClass>ACP</EventClass></DataRow></ResultSet>

    Or if you have oracle version >= 10gR2 then this is better:
    select b.* from
      (SELECT xmltype(:your_xml) your_xml FROM dual) a,
      XMLTable
      ('/ResultSet/DataRow'
        PASSING a.your_xml
        COLUMNS
          EventNumber varchar2(10) PATH '/DataRow/EventNumber',
          EventDesc varchar2(10) PATH '/DataRow/EventDesc'
      ) bBest regards,
    Hrvoje.

  • Extract data from xml file to Oracle table

    hello to all members of forum..i have this stored procedures:
    create or replace
    PROCEDURE INSERTXML2(
    p_xml_in XMLType,
    p_table IN VARCHAR2 ) AS
    v_context DBMS_XMLStore.ctxType;
    v_rows NUMBER;
    BEGIN
    insCtx := DBMS_XMLStore.newContext(p_table); -- get saved context
    dbms_xmlstore.setRowTag(insCtx,'Row');
    DBMS_XMLStore.clearUpdateColumnList(insCtx); -- clear the update settings
    -- set the columns to be updated as a list of values
    DBMS_XMLStore.setUpdateColumn(insCtx,'ORDERNUMBER');
    DBMS_XMLStore.setUpdateColumn(insCtx,'PLANT');
    DBMS_XMLStore.setUpdateColumn(insCtx,'MATERIAL');
    DBMS_XMLStore.setUpdateColumn(insCtx,'LINENUMBER');
    DBMS_XMLStore.setUpdatecolumn(insCtx,'NOMSPEED');
    DBMS_XMLStore.setUpdatecolumn(insCtx,'STARTDATE');
    DBMS_XMLStore.setUpdatecolumn(insCtx,'FINISHDATE');
    DBMS_XMLStore.setUpdatecolumn(insCtx,'TARGETQTY');
    DBMS_XMLStore.setUpdatecolumn(insCtx,'UNIT');
    DBMS_XMLStore.setUpdatecolumn(insCtx,'SYSTEMSTATUS');
    v_rows := DBMS_XMLStore.insertXML(insCtx, xmldocument);
    -- Close the context
    DBMS_XMLStore.closeContext(insCtx);
    END;
    that works well in little XML files but in XML files that are bigger the stored procedures to not work because string maximum length in Oracle is 4000..can anyone know a solution to pass over this problem?!?!
    one more thing im working with Oracle SQL Developer and Sap Mii, the XML file is generated in Sap Mii and then i have to pass it in one step to database..my one step is this stored procedure
    one more thing im working with Oracle SQL developer and SAP Mii
    regards and thanks in advance
    matinha
    Edited by: user11098081 on 23/Abr/2009 7:11

    You can use CLOB for big files.
    http://saubbane.blogspot.com/2010/12/saving-xml-file-into-table-with-plsql.html

  • 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=

  • How to extract data from XML file with JavaScript

    HI All
    I am new to this group.
    Can anybody help me regarding XML.
    I want to know How to extract data from XML file with JavaScript.
    And also how to use API for XML
    regards
    Nagaraju

    This is a Java forum.
    JavaScript is something entirely different than Java, even though the names are similar.
    Try another website with forums about JavaScript.
    For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3

  • Hi, extract data from xml file and insert into another exiting xml file

    i am searching code to extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
    1st xml file which has two lines(text1.xml)
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xs:PrintDataRequest xmlns:xs="http://com.unisys.com/Anid"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
    <xs:Person>
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
    These two lines has to be inserted in the existing another xml(text 2.xml) file(at line 3 and 4)
    Regards,
    bubbly

    Jadz_Core wrote:
    RandomAccessFile? If you know where you want to insert it.Are you sure about this? If using this, the receiving file would have to have bytes inserted that exactly match the number of bytes replaced. I'm thinking that you'll likely have to stream through the second XML with a SAX parser and copy information (or insert new information) as you stream with an XML writer of some sort.

  • Extract data from xml file and insert into another exiting xml fil

    hello,
    i am searching extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
    Regards,
    Zhuozhi

    If the files are small, you can load the target file in a DOM document, insert the data from the source file and persist the DOM.
    If the files are large, you probably want to use a StAX or SAX.

  • 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.

  • Extracting data from XML

    Im fairly new to XML & web services so bear with me please.
    Im trying to extract data from XML documents where the structure/element names are unknown.
    The condition for extracting data is if keyword matches some data content.
    Im using Java and the DOM API with xcerces and I've managed to parse the XML file, what I need to do next is to traverse the data content checking against keywords and if a keyword matches then to strip the tags and save the data locally ?
    Ive trawled through all the documentaion but as theres so many different methods Im somewhat unsuare which is the best way to proceed.
    thanks

    tough question, i would suggest looking at jdom as solution for you, because it is a relatively simple one to use for searching through a dom. aside from that, its probably up to you what sort of logic you want to use.

  • Extracting data from xml spreadsheet for JSP

    Hi,
    Currently i am developing a web application where user can upload a MS excel file, then the application will extract data needed and store into database. But facing problems where those excel files may content massive images that make the file size too large to be upload on to the web. Now i try to export those excel files into xml spreadsheet, to get only text data. Need helps on how to extract data from xml spreadsheet. Which API needed?
    Thanks

    Without getting into too much detail, a DTD defines the elements that can appear in an xml file, the order they can appear in, which elements can be nested within which other elements, what each element can contain, etc, etc. In short, a DTD defines the structure of the xml file and Microsoft defined a DTD for the xml files that are output by Excel.
    This is not taken from an xml file produced by Excel but DTDs look a llittle like this very basic example.
    <!DOCTYPE note [
      <!ELEMENT note (to,from,heading,body)>
      <!ELEMENT to      (#PCDATA)>
      <!ELEMENT from    (#PCDATA)>
      <!ELEMENT heading (#PCDATA)>
      <!ELEMENT body    (#PCDATA)>
    ]>If you open the one produced for you by Excel in Wordpad or another simple text editor, you may see something like this in there.
    However, if you are going to use a parser to access the file for you do not worry about getting to grips with DTDs for a short, simple project.

  • How to extract data from xml file and store that data inti data base table

    Hii All
    I have one table that table contains one column that column contain an XML file
    I want to extract data from that XML file and want to store that extracted data into an other table.
    That xml file has different different values
    I want to store that values into table in diff diff columns

    Hi,
    I am also facing the same problem.I have a .xml file and i need to import the data into the custom table in oracle database.
    Can you please let me know if you know the solution how to do it in oracle apps.
    Thanks,

  • Import/insert data from XML into Oracle database tables?

    Hi. (I am using JDeveloper 10.1.3.3.0 and Oracle 10g)
    I have been able to export the data from one of my database tables by using a View Object and .writeXML.
    Now, I want to take an xml file that is formatted in the same way as what is spit out by the writeXML and put that info in my database table. I followed online examples and have tried using .readXML like so:
    Element element = XMLDoc.getDocumentElement();
    vo.readXML(element, -1);
    I know it is sort of working, because at first I got an error message that one of the required attributes was missing. So, I added that attribute to my xml file and ran my code. No errors. But, I checked my database, and the new records were not added.
    Is there something I have done wrong? Or is there perhaps something I left out? I also noticed there were several versions of readXML like readFromXML. Which one should I use and how?
    Thanks.

    KUBA, I changed my code to match your example:
    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    File xmlFile = new File("C:/myfilehere.xml");
    Document doc = db.parse(xmlFile);
    Element element = doc.getDocumentElement();
    vo.readXML(element, -1);
    vo.getDBTransaction().commit();
    I still get no errors, but my database table has no new records.
    Any ideas why?
    Thanks.

  • How to copy data from one column to other column

    hi,
    can any one tell me how to copy data of  one column to other column for some specific data
    example
    productno  ocalyear        actualsales  prevplansales   currentplansales
    p001       2007                  100              120                   
    p002       2007                   90               100
    p003       2007                  120              130
    p004       2007                  140              120
    p005       2007                  150              150
    i want to copy data of p001 and p002 from prevplansales to current plansales
    productno  ocalyear        actualsales  prevplansales   currentplansales
    p001       2007                  100              120              120     
    p002       2007                   90               100              100
    p003       2007                  120              130
    p004       2007                  140              120
    p005       2007                  150              150
    is it possible to do?
    please suggest me.
    i will assign points

    Hi,
    I think the needed techniques are already described in the documentation, e.g. in
    http://help.sap.com/saphelp_nw70/helpdata/en/45/e641e4c61256dee10000000a114a6b/frameset.htm
    or
    http://help.sap.com/saphelp_nw70/helpdata/en/45/e641e4c61256dee10000000a114a6b/frameset.htm
    The main techiques used in the above example to bind the filter of the planning function to selected (marked) objects in the analysis item or to drop down boxes (or both). These techniques are used in the above examples.
    Regards,
    Gregor

  • How to retreive soap xml data from clob column in a table

    Hi,
    I am trying to retrieve the XML tag value from clob column.
    Table name = xyz and column= abc (clob datatype)
    data stored in abc column is as below
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://www.abc.com/gcgi/shared/system/header" xmlns:v6="http://www.abc.com/gcgi/services/v6_0_0_0" xmlns:sys="http://www.abc.com/gcgi/shared/system/systemtypes">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <RqHeader soapenv:mustUnderstand="0" xmlns="http://www.abc.com/gcgi/shared/system/header">
    <DateAndTimeStamp>2011-12-20T16:02:36.677+08:00</DateAndTimeStamp>
    <UUID>1000002932</UUID>
    <Version>6_0_0_0</Version>
    <ClientDetails>
    <Org>ABC</Org>
    <OrgUnit>ABC</OrgUnit>
    <ChannelID>HBK</ChannelID>
    <TerminalID>0000</TerminalID>
    <SrcCountryCode>SG</SrcCountryCode>
    <DestCountryCode>SG</DestCountryCode>
    <UserGroup>HBK</UserGroup>
    </ClientDetails>
    </RqHeader>
    <wsa:Action>/SvcImpl/bank/
    SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq</wsa:Action></soapenv:Header>
    <soapenv:Body>
    <v6:AlertDeleteInqRq>
    <v6:Base>
    <v6:VID>20071209013112</v6:VID>
    <!--Optional:-->
    <v6:Ref>CTAA00000002644</v6:Ref>
    </v6:Base>
    </v6:AlertDeleteInqRq>
    </soapenv:Body>
    </soapenv:Envelope>
    And i want to retrieve the values of tag
    <ChannelID> and <v6:VID>
    can somebody help, i have tried with extractvalue but not able to get the values

    I have used the below two queries but not able to get the expected results. Both queries result into no values.
    select xmltype(MED_REQ_PAYLOAD).extract('//ClientDetails/Org','xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" || xmlns="http://www.abc.com/gcgi/shared/system/header"').getStringValue() from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/alerts/v6_0_0_0/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
    select EXTRACTVALUE(xmltype(MED_REQ_PAYLOAD),'/RqHeader/) from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
    Well, for starters, both queries are syntactically wrong :
    - non terminated string
    - incorrect namespace mapping declaration
    - unknown XMLType method "getStringValue()"
    Secondly, all those functions are deprecated now.
    Here's an up-to-date example using XMLTable. It will retrieve the two tag values you mentioned :
    SQL> select x.*
      2  from esb_output_temp t
      3     , xmltable(
      4         xmlnamespaces(
      5           'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
      6         , 'http://www.abc.com/gcgi/shared/system/header' as "head"
      7         , 'http://www.abc.com/gcgi/services/v6_0_0_0' as "v6"
      8         )
      9       , '/soap:Envelope'
    10         passing xmlparse(document t.med_req_payload)
    11         columns ChannelID  varchar2(10) path 'soap:Header/head:RqHeader/head:ClientDetails/head:ChannelID'
    12               , VID        varchar2(30) path 'soap:Body/v6:AlertDeleteInqRq/v6:Base/v6:VID'
    13       ) x
    14  ;
    CHANNELID  VID
    HBK        20071209013112
    You may also want to store XML in XMLType columns for both performance and storage optimizations.

Maybe you are looking for