How to store XML fragments in a XMLTYPE column

Hi all,
maybe just another newbie question.
I've imported a lot of xml documents into an Oracle table with a xmltype column (stored as CLOB). Now I try to select a specific part of these documents and store thsi xml fragment in another table, also in a xmltype column.
Unfortunately this doesn't work, I get ORA-19010: Cannot insert XML fragments.
What can I do to store part of a xml document?
Best regards
Matthias

Is there a way to transform the xml fragments into valid xml documents?

Similar Messages

  • How To Store XML Fragments Using Functions Such As XMLElement

    Hi
    Not sure what I am missing. I wish to store XML fragments in variables so can pass around and concatenate with other fragments to make final XML document. Even before attempting to concatenate XML fragments, I am struggling to store any XML fragment in a variable. I am trying to use simple functions such as XMLElement to generate XML so can store in variable. I have seen many examples of XMLElement in SQL select statement. Can XMLElement be used in plsql? XMLElement says it returns value of type XMLType. Functions such as XMLElement make generating XML easier than creating all tags manually.
    Below is simple example that demonstrates what I would like to do. I would like to be able to pass the XML fragment as either XMLType or clob. I receive error saying PLS-00201: identifier 'XMLELEMENT' must be declared
    declare
    vTheData XMLType;
    vTheDataClob clob;
    begin
      vTheData:= XMLelement("empno",'1234567');
      vTheDataClob:= xmlelement("empno",'1234567').getclobval();
    end;
    Where as I can use below, but surely don't have to use select into from dual method. I just expect can use XMLElement function in plsql same as sql, such as most other functions eg length, rtrim etc.
    declare
    vTheData XMLType;
    vTheDataClob clob;
    begin
      select xmlelement("empno",'1234567')
      into vTheData
      from dual;
      select xmlelement("empno",'1234567').getclobval()
      into vTheDataClob
      from dual;
    end;
    Hope this makes sense.
    Thanks

    Having said that, is there a more elegant way to achieve below. That is populate two XML fragments and concatenate together.
    Sure, why not just only one statement?
    select XMLConcat(
             XMLElement( ... )
           , XMLElement( ... )
    into vTheResult
    from dual;
    As a second question, is it better to build and pass XML fragments as XMLType or clob?
    I would say stay with XMLType but it depends on your requirement.
    I generally avoid passing around pieces of data, SQL/XML functions are powerful in the way they can be used with set operations, so using them in a piecewise approach kinda negates what they're for.

  • How to use XML fragment in BPEL?

    Hello,
    How to use XML fragment in BPEL process and whats the purpose of XML fragment ? And why we need it ??

    It is used to build up an XML fragment to the element on the target side...
    please refer this link....
    http://kr.forums.oracle.com/forums/thread.jspa?threadID=2252997&tstart=2
    Thanks,
    N

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • LPX-00004 - Problems while inserting xml files in a xmltype column

    I've faced two problems while trying to insert xml files into my table containing a xmltype column:
    create table xml_test (id number(20),content xmltype)
    I use following java code for writing xml docs into db:
         conn.setAutoCommit(false);
         OraclePreparedStatement stmt = (OraclePreparedStatement)
              conn.prepareStatement("INSERT INTO xml_test (id,content) VALUES(?,?)");
         File file = new File(file1);
         InputStream in1 = new FileInputStream(file1);
         Reader r1 = new BufferedReader(new InputStreamReader(in1, "UTF-8"));
         int len = 0;
         StringBuffer text = new StringBuffer();
         while ((len = r1.read()) != -1) {
              text.append((char) len);
         in1.close();
         r1.close();
         XMLType poXML1 = XMLType.createXML(conn, text.toString());
         for (int i = 1; i <= 1; i++) {
              stmt.setInt(1, i);
              stmt.setObject(2, poXML1);
              stmt.execute();
         conn.commit();
    1. problem: occures only if a xml schema has been assoicated to the specific xmltype column. it seems that the length of a specific xml tag in the document is limited. but why?
    java.sql.SQLException: ORA-22814: attribute or element value is larger than specified in type
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
         at test.insertXML(test.java:84)
         at test.main(test.java:261)
    hier the xml-schema of the xmltype column "content":
    <?xml version="1.0" encoding="UTF-8"?>
    <!--W3C Schema generated by XML Spy v4.4 U (http://www.xmlspy.com)-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:element name="AUTOR-ID" type="xs:string"/>
         <xs:element name="BODY" type="xs:string"/>
         <xs:element name="CONTENT">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="METADATEN"/>
                        <xs:element ref="BODY"/>
                   </xs:sequence>
                   <xs:attribute name="content-id" type="xs:string" use="required"/>
              </xs:complexType>
         </xs:element>
         <xs:element name="DATUM" type="xs:string"/>
         <xs:element name="KEYWORD" type="xs:string"/>
         <xs:element name="METADATEN">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="DATUM"/>
                        <xs:element ref="TITEL" maxOccurs="unbounded"/>
                        <xs:element ref="KEYWORD" maxOccurs="unbounded"/>
                        <xs:element ref="AUTOR-ID"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:element name="TITEL" type="xs:string"/>
    </xs:schema>
    2. problem: hier i have no idea what is happening ... please help
    java.sql.SQLException: ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00004: internal error "MultiChar overflow"
    Error at line 61
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
         at test.insertXML(test.java:53)
         at test.main(test.java:259)

    It's hard for me to tell you more without seeing your instance data, but for problem #1, if you look at the underlying SQL types being generated by your schema, you will see that the default SQL mapping for a "string" in your schema is a VARCHAR2(4000) (and I believe this would be only 2000 for a varying width character set like UTF8).
    You can specify that you wish this column to be mapped as a CLOB in your schema if this is the problem. Also note that there is a 64K limit on the size of an individual node in XMLType.

  • How to store xml data fragments, that will not be queried?

    Hello,
    Delphi Client application communicates with Java Server application via XML messages. Client sends XML message over HTTP Post method. Java Servlet gets XML message, parses it, performs requested action (select/insert/update/delete), generates resulting response and sends it back to the Client.
    I use Oracle DB XE 10.2.
    For example: Client sends a request to the server, to append certain Order with new Product info:
    Request:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <Request OrderID="123123123" Action="NewProduct">
    - <Product TempProdID="2" ProdName="L01" VisualID="1" Amount="1" TechClass="1" TechSubject="1" TechVersion="0" TechName="TestTech" ElemOk="0">
    <Modified UserID="XXX" UserGroup="XXX" GroupLevel="0" />
    - <QuickInfo>
    <ProdIcon Format="PNG"
    Encoding="Base64">iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAA
    lC+aJAAAAA3RSTlP////6yOLMAAAAvElEQVR42u3aQQ6EIAwAQP7/afe0
    mo1mBVur0emJgwGmRDFNWwvH9I153OpjyoisefqXW3afm4WypP+MgomvT
    z8AAAAAAAAAAAAAAMAzAClzAWQAdvexfqATEKmA/Fm0rYs5ozvoAWyWj4
    ZqJ9efQKR8BJAHOPEdKAAc/lLdAhC/K68EBG+JWwAixfABgF8Jf6MAAAA
    AAAAAAAAAAAAALwRUGgAAAAAAsgGJ3cfVrcfFl2jiIZzV+V7Zd/8BOtNi
    0MnJ58oAAAAASUVORK5CYII=
    </ProdIcon>
    <Parameters />
    </QuickInfo>
    - <TechProduct CurVer="1" MinVer="1" TotalItems="330" ItemNodeSize="55074">
    - <SubItem Class="TPlGraph" BindID="00B9C004">
    <PropList />
    - <SubItem Ident="Profiles" Class="TProfileList" Child="1" BindID="0188598C">
    <PropList />
    - <SubItem Class="TPlProfile" Child="1" BindID="018CA6CC">
    - <PropList>
    <Property PropIdent="ProfBaze0X" ValText="0" />
    <Property PropIdent="ProfBaze0Y" ValText="990" />
    <Property PropIdent="ProfBaze1X" ValText="990" />
    <Property PropIdent="ProfHier0" ValText="0" />
    - <Property PropIdent="InBorder" ValIdent="None" ValText="N&#279;ra">
    <ExtValue ColIdent="ItemCode" Value="None" />
    <ExtValue ColIdent="Type" Value="" />
    <ExtValue ColIdent="Filter" Value="" />
    <ExtValue ColIdent="Width" Value="0" />
    <ExtValue ColIdent="TechCall" Value="" />
    </Property>
    </PropList>
    </SubItem>
    </SubItem>
    </SubItem>
    </TechProduct>
    </Product>
    </Request>
    I use DOM parsers to parse the received requests, extract certain info and insert it into relational tables using standart SQL queries.
    My question is: what is the best way to store XML data fragments, that are not required to be saved relationally? I need to save the content of node <TechProduct> from the above example to relational table's column. There will be no need to query this column, no need to use relational views. I will use it only when Client application will request to modify certain order's product. Then I will have to send back the same <TechProduct> node via XML response.
    So what column type do I have to use? CLOB? XMLType? Is it better to use object types? Do I have to register XML Schema for better performance? The size of the fragment can be ~2MB.
    Thanks for your help
    Message was edited by:
    Kichas

    Thank you for reply,
    As you suggested, I will use XMLType storage as CLOB (without XML Schema).
    As I mentioned before, I use Java Servlet, deployed on Tomcat WebServer, to receive XML messages from Client application via HTTP POST method.
    I use these libs to get the XML payload and parse it into a Document:
    import org.w3c.dom.*;
    import org.xml.sax.InputSource;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    And here is the code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
    // get the XML payload and parse it into a Document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document dom;
    InputSource input = new InputSource(request.getInputStream());
    dom = docBuilder.parse(input);
    catch(Exception ex) {
    System.out.println("Exception thrown in XmlService");
    ex.printStackTrace();
    throw new ServletException(ex);
    I create a relational table, that contains XMLType column:
    CREATE TABLE xwarehouses (
    warehouse_id NUMBER,
    warehouse_spec XMLTYPE)
    XMLTYPE warehouse_spec STORE AS CLOB;
    Now I want to insert all DOM Document into XMLType column. So I do like this:
    import oracle.xdb.XMLType;
    String SQLTEXT = "INSERT INTO XWAREHOUSES (WAREHOUSE_ID, WAREHOUSE_SPEC) VALUES (?, ?)";
    XMLType xml = XMLType.createXML(con,dom);
    PreparedStatement sqlStatement = con.prepareStatement(SQLTEXT);
    sqlStatement.setInt(1,2);
    sqlStatement.setObject(2,xml);
    sqlStatement.execute();
    sqlStatement.close();
    dom is the Document, that I got from HTTP Request input stream.
    My servlet throws an exception:
    java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
    at XmlService.GetMatListServiceHandler.processRequest(GetMatListServiceHandler.java:111)
    at XmlService.XmlServiceHandler.handleRequest(XmlServiceHandler.java:43)
    at XmlService.XmlServiceServlet.doPost(XmlServiceServlet.java:69)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    why does he needs oracle.xml.parser.v2.XMLParseException? I don't use Oracle parser? Does this code line throws the exception (I am not able to debug my code, because I have not configured JDeveloper to be able to use Remote Debuging):
    XMLType xml = XMLType.createXML(con,dom);
    Does it reparses the given dom Document or what?. When I deploy xmlparserv2.jar to Tomcat, everything is ok, application inserts XML data into XMLType column.
    Is there another way to insert the whole org.w3c.dom Document or Document fragment (that is already parsed) into XMLType column. Can you provide any sample code?
    The Document may contain national symbols, so they should be correctly stored and then later retrieved.
    Many thanks.

  • Store XML-fragment without Namespace Information

    Hello,
    I register a schema, create a table with a XMLTYPE column, insert a row and create a view to query the data.
    ALTER SESSION SET nls_numeric_characters = '.,';
    BEGIN
        dbms_xmlschema.registerSchema(
             'http://test_datetime.xsd'
            ,q'[<?xml version="1.0" encoding="WE8ISO8859P1" standalone="no"?>
    <xs:schema xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" targetNamespace="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99" elementFormDefault="qualified">
      <xs:element name="Document" type="Document"/>
        <xs:complexType name="Document">
            <xs:sequence>
                <xs:element name="CreDtTm" type="ISODateTime"/>
            </xs:sequence>
        </xs:complexType>
        <xs:simpleType name="ISODateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE">
            <xs:restriction base="xs:dateTime"/>
        </xs:simpleType>
    </xs:schema>]'
            ,TRUE
            ,FALSE
            ,FALSE
    END;
    CREATE TABLE test_datetime (
         id             NUMBER
        ,xml_document   XMLTYPE
        XMLTYPE COLUMN xml_document
        ELEMENT "pain.001.002.99.xsd#Document";
    INSERT INTO test_datetime (id,xml_document)
        VALUES (
             1
            ,XMLTYPE(
    q'[<?xml version="1.0" encoding="UTF-8"?>
    <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99
    pain.001.002.99.xsd">
    <CreDtTm>2012-06-02T09:30:47.000Z</CreDtTm>
    </Document>]')
    COMMIT;
    CREATE OR REPLACE VIEW v_dateTime_xml AS
    SELECT  created.CreationDateTime
           ,created.CreDtTm
    FROM    test_datetime,
            XMLTABLE(XMLNAMESPACES(DEFAULT 'urn:iso:std:iso:20022:tech:xsd:pain.001.002.99'),
                '/Document'
                PASSING test_datetime.xml_document
                COLUMNS
                 CreationDateTime TIMESTAMP WITH TIME ZONE  PATH 'CreDtTm'
                ,CreDtTm          XMLTYPE                   PATH 'CreDtTm'
                ) created;I want to store the element CreDtTm in another table to use it later without recreating it (in my real code it is not a simple element, but a fragment with many elements).
    Yet the selected element contains the schema information
    <CreDtTm xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99">2012-06-02T09:30:47.000000+00:00</CreDtTm>Therefore, when I later use it in another XML document it is includes together with the xmlns attribute.
    SELECT  XMLELEMENT(
                 "Document"
                ,XMLAttributes(
                     'urn:iso:std:iso:20022:tech:xsd:pain.001.002.99' AS "xmlns"
                    ,'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
                    ,'urn:iso:std:iso:20022:tech:xsd:pain.001.002.99 pain.001.002.99.xsd' AS "xsi:schemaLocation"
                ,(  SELECT  XMLAGG(CreDtTm)
                    FROM    v_dateTime_xml
    FROM    dual;
    <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99 pain.001.002.99.xsd">
    <CreDtTm xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.002.99">2012-06-02T09:30:47.000000+00:00</CreDtTm>
    </Document>How can I store or retrieve it without the schema information?
    Regards
    Marcus
    Edited by: Marwim on 08.08.2012 14:06
    Corrected schema

    P.S.: Perhaps something dirty likeSure, you can always do that :)
    Here are two examples with XQuery or XSLT :
    SQL> var xsldoc varchar2(4000)
    SQL>
    SQL> begin
      2 
      3   :xsldoc := '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      4    <xsl:output method="xml" omit-xml-declaration="yes"/>
      5    <xsl:template match="*">
      6      <xsl:element name="{local-name()}">
      7        <xsl:apply-templates select="@*|*|text()"/>
      8      </xsl:element>
      9    </xsl:template>
    10    <xsl:template match="@*|text()">
    11      <xsl:copy/>
    12    </xsl:template>
    13  </xsl:stylesheet>';
    14 
    15  end;
    16  /
    PL/SQL procedure successfully completed
    SQL>
    SQL> SELECT XMLQuery(
      2         'declare function local:strip-ns($e as element()) as element()
      3          {
      4            element {local-name($e)}
      5            {
      6              for $i in $e/(@*|node())
      7              return typeswitch ($i)
      8                       case element() return local:strip-ns($i)
      9                       default return $i
    10            }
    11          }; local:strip-ns(*)'
    12          passing x.CreDtTm
    13          returning content
    14         ) as "XQuery method"
    15       , XMLTransform(x.CreDtTm, :xsldoc) as "XSLT method"
    16  FROM test_datetime
    17     , XMLTable(
    18         XMLNamespaces(default 'urn:iso:std:iso:20022:tech:xsd:pain.001.002.99')
    19       , '/Document'
    20         PASSING test_datetime.xml_document
    21         COLUMNS CreDtTm   XMLTYPE PATH 'CreDtTm'
    22       ) x
    23  ;
    XQuery method                                                                    XSLT method
    <CreDtTm> 2012-06-02T09:30:47,000000+00:00</CreDtTm>                             <CreDtTm> 2012-06-02T09:30:47,000000+00:00</CreDtTm>

  • How to store xml-file direct on file-directory on server ?

    Hello,
    I have created a xml-data by using xmlelements, xmlforest .... and so on in a sql-statement and want to store it as file in a ( windows) server-directory.
    I can find some samples to store it in XML-DB by using dbms_xmlGEN and dbms_XDB,
    but how to store it direct ?
    thank you
    Norbert

    Try dbms_xmldom.writeToFile()..
    Or create a resource from your SQL Statement using dbms_xdb.createResource() and then access the resource via FTP or HTTP

  • How to store XML data into Oracle Table

    I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
    C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
    <Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2263)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
    at testInsert.main(testInsert.java:8)
    Here is my xml file:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <DEPTNO>10</DEPTNO>
    <DNAME>ACCOUNTING</DNAME>
    <LOC>NEW YORK</LOC>
    </ROW>
    <ROW num="2">
    <DEPTNO>20</DEPTNO>
    <DNAME>RESEARCH</DNAME>
    <LOC>DALLAS</LOC>
    </ROW>
    <ROW num="3">
    <DEPTNO>30</DEPTNO>
    <DNAME>SALES</DNAME>
    <LOC>CHICAGO</LOC>
    </ROW>
    <ROW num="4">
    <DEPTNO>40</DEPTNO>
    <DNAME>OPERATIONS</DNAME>
    <LOC>BOSTON</LOC>
    </ROW>
    </ROWSET>
    and here is structure of table:
    Name Null? Type
    DEPTNO NOT NULL NUMBER(2)
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    and here is my Java Code:
    import java.sql.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert{
         public static void main(String[] args) throws SQLException{
              Connection conn = getConnection();
              OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
              sav.insertXML(args[0]);
              sav.close();
              conn.close();
         private static Connection getConnection()throws SQLException{
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
              return conn;
    Could you help me ? Thanks !

    The problem is that you need to pass avalid URL , Document...
    Please try this code instead:
    import java.net.*;
    import java.sql.*;
    import java.io.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert
    public static void main(String[] args) throws SQLException{
    Connection conn = getConnection();
    OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
    URL url = createURL(args[0]);
    sav.insertXML(url);
    sav.close();
    conn.close();
    private static Connection getConnection()throws SQLException{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
    return conn;
    // Helper method to create a URL from a file name
    static URL createURL(String fileName)
    URL url = null;
    try
    url = new URL(fileName);
    catch (MalformedURLException ex)
    File f = new File(fileName);
    try
    String path = f.getAbsolutePath();
    // This is a bunch of weird code that is required to
    // make a valid URL on the Windows platform, due
    // to inconsistencies in what getAbsolutePath returns.
    String fs = System.getProperty("file.separator");
    if (fs.length() == 1)
    char sep = fs.charAt(0);
    if (sep != '/')
    path = path.replace(sep, '/');
    if (path.charAt(0) != '/')
    path = '/' + path;
    path = "file://" + path;
    url = new URL(path);
    catch (MalformedURLException e)
    System.out.println("Cannot create url for: " + fileName);
    System.exit(0);
    return url;

  • How to marshal XML fragments with JAXB

    Hello,
    I have Object unashamed from XML. I would like to insert part of this object in another XML document. I�m using Cocoon Transformer for this. In startElement then I detect element which I would like replace I would like to write something like this:
    Marshaller m = jc.createMarshaller();
    m.marshal(myElem, contentHandler);
    However this method try to marshal it as whole document with: <?xml version="1.0" encoding="UTF-8" ?> This probably case problems for next Transformer.
    I have this problem in Cocoon and with SAX, but there should be some general solution to marshal JAXB objects as XML fragments, not whole documents. However I can�t found it.
    Thanks for any help
    Arek Stryjski

    In JAXB mailing list I got this answer:
    It currently doesn't have any explicit support for fragment marshalling,
    but like you said, you can easily write an XMLFilter that blocks
    start|endDocument. In your case, you just need to:
    Marshaller m = jc.createMarshaller();
    m.marshal(myElem, new FragmentFilter(contentHandler));
    where FragmentFilter is:
    class FragmentFilter extends XMLFilterImpl {
    FragmentFilter( ContentHandler handler ) {
    setContentHandler(handler);
    public void startDocument() {}
    public void endDocument() {}
    Perhaps this could be another example.
    regards,
    Kohsuke KAWAGUCHI

  • How to store XML files

    Hi experts,
    I have an abap applicatrion that has to store xml files received from a web service.
    Where is better to store these files, in sap transparent tables or in the IXOS for example?
    Thanks

    Brad,
    An java application will call that BAPI passing the XML when error occurs in the process. The XML will contain the error details.
    I want to associate the error messages with the respective XMLs.
    What do you mean with  "object type / object value" ?
    Thanks
    Edited by: Jorge Castro on Jan 18, 2011 5:09 PM

  • How to use XML data stored in table column in XML Data Definition

    Hi,
    We are using BIP 5.6.3 (Oracle EBS R12).
    We have a table which stores XML data in a column. Is there a way we can use this XML data through a SQL query in XML Data Definition of BI Publisher report instead or writing whole SQL query to fetch same data from Oracle EBS?
    Can some please provide a sample SQL query that we should use in Data Definition?
    Thanks!

    Mark,
    Thanks. This is exactly what I was looking for.
    After doing @Name in both places (SELECT and WHERE clause) it worked.
    Now I have one more question.
    There are multiple DIMENSION tags in my xml, and I want to see the NAME attribute values for all of those DIMENSIONs. The following query returns
    ORA-19025: EXTRACTVALUE returns value of only one node.
    Cause: Given XPath points to more than one node.
    Action: Rewrite the query so that exactly one node is returned.
    SELECT
    extractValue(value(x), '/AW/@Name') as "AW",
    extractValue(value(x), '/AW/Dimension/@Name') as "DIMENSIONS"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/@Name') = 'OMCR4'

  • How to use SQL*Loader to load XMLType Column with other columns?

    Hi,
    I am trying to use sqlldr to load an XML file into a table with an XMLType column. I have found plenty of examples where the entire table is an xmltype, but I would like to load many XML objects into a generic table for processing with one XMLType column and many other columns to identify the load. As a simple example, I have one constant column which I want to set during the upload.
    The following example does not work :(. No errors either.
    create table xml_upload
    (upload_type varchar2(10) not null,
    xml_data XMLType)
    my control file:
    LOAD DATA
    INFILE * append
    INTO TABLE xml_upload
    XMLType(xml_data)
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    upload_type constant MARKET,
    xml_data
    BEGINDATA
    <SALE_ORDER>
    <CUST_CODE>TIM</CUST_CODE>
    <ORDER_NUM>1234></ORDER_NUM>
    </SALE_ORDER>
    $ sqlldr my.ctl
    SQL*Loader: Release 10.2.0.4.0 - Production on Sun Sep 27 22:51:52 2009
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    Commit point reached - logical record count 4
    SQL> select * from xml_upload;
    no rows selected
    SQL>
    Any ideas on how I can do this? Am I missing something...
    I have also been playing with the lobfile clause of sqlldr, also without any success...
    Current database version is 10g R2.
    Thanks,
    Tim.

    Hi,
    I tried the same example as it is. but, I am getting the following error:
    SQL*Loader-350: Syntax error at line 6.
    Expecting valid column specification, "," or ")", found "filler".
    ,file_name  char(100) fillerThe table I created is:
      create table xml_upload
    (upload_type varchar2(10) not null,
    xml_data XMLType)The control file I used is:
    LOAD DATA
    INFILE *
    INTO TABLE xml_upload TRUNCATE
    upload_type constant 'MARKET'
    ,file_name  char(100) filler
    ,xml_data LOBFILE (file_name) TERMINATED BY EOF
    BEGINDATA
    test.xmlThe database I am using is 10gr2

  • How to upload as one row in xmltype column using sqlloader

    I have the file test.xml which has data as shown below
    <?xml version="1.0" encoding="ISO-8859-1">-<ops> <op><op_type>A</op_type><ent_type>A</ent_type></op>
    <op><op_type>A</op_type><ent_type>A</ent_type></op>
    </ops>
    I need the entire data to be loaded as one row to a xmltype column.
    How can I do this using sqlloader?
    I tried the following, but it works only if everything is in one line.
    LOAD DATA
    INFILE 'test.xml'
    INTO TABLE poc
    (content char(1000) ENCLOSED BY '<ops>' AND '</ops>')
    Is there an EOF option?

    XML questions (and answers) are better suited to the XDB forum...
    XML DB
    But in answer to your question, I don't think sqlloader is the best tool to be using for loading XML data into your database. The XDB forum has loads of examples of how to load XML into database tables.

  • Multiple XML schema in structured XMLType column possible?

    I have registered several different xml schema in my 10g database. I have a table with an XMLType column. That column will always hold one XML document that conforms to one of the XML schema. Question: does that by definition mean I have to use "unstructured" storage, or there any way to use structured storage telling Oracle that the XMLType conforms to xsd1 OR xsd2 OR xsd3?
    Thanks.

    In 10gR2 a column based on an XML Schema and using object-relation storage can be bound to one global element. The only way for a column to hold documents associated with more than one global element is if both elements are defined as members of the same substition group.

Maybe you are looking for

  • Message in a method

    Hello, I need to display a method within a BADI and send out a message of type E without stop completely the transaction,but instead let the user to correct the eventual error. Do you need if there are any other way instead of the normal message e000

  • IDVD 6 problems - crashes and bizarre memory error

    I've got an iMovie project that I'm trying to put to disc with iDVD. On my MDD G4 with an ATI9800 it just crashes out after a certain period of time whilst doing the menus. EXCBADACCESS (0x0001) KERNPROTECTIONFAILURE (0x0002) at 0x00000000 Thread 12

  • What's wrong with my Mac App store.

    It says I have insufficient funds for my purchase for Grand Theft Auto: San Andreas ($14.99). But I have more than enough money to buy it($15.31). What's going on

  • Display a checkbox in cfgridcolumn?

    I'm using CF8. I have an HTML-format cfgrid with several columns, populated via a CFC in the bind attribute. One of the columns I have set to type="boolean" in order to display a checkbox. However, no mater what data I send to it, it displays the dat

  • Nokia Asha 501 - Some apps are not supported

    i have see some applications are not supported why? Moderator's Note: The title of this post has been edited as it is created as a new topic.