BLOB ibfo into XML document

Hi forumers,
I've been asked to build a table to keep some data in XML format. Actually this data resides in a relational table and one of the columns is BLOB.
Can I store BLOB in a XML document ? (for the other columns I'm using XMLFOREST()).
If this is possible and if I want to "extract" this BLOB information from XML document how can I do this ?
Best Regards,
Helena

Correction made on the subject

Similar Messages

  • Transform Java Beans into XML documents?

    Hi,
    I have standard Java Beans (which are not generated out of XML documents), can I transform them into
    XML documents even if they are not generated out of XML documents originally?
    If not, is there any toll which can do that?
    regards,

    Looks like the java.beans.XMLEncoder class is where you should start.

  • Embeding image into XML document

    Hi,
    I am in need to embed image into XML file so that when somebody else uses the XML file, the image is still there. Is there any way to do this? Is it possible? Please give me some suggestions if you know about.
    Thanks a lot.

    well, the blowup in size from 3MB to 5MB is expected when you do the text encoding, cause you are taking binary data and converting it to a small range of characters. there are alternate algorithms which result in less of a blowup than base64 (like ascii85), see:
    http://en.wikipedia.org/wiki/Category:Binary-to-text_encoding_formats
    most image files use some sort of compression algorithm, which is why your file is much smaller than the image byte[]. you could just stick the file byte[] in the xml, but you might need to add additional attributes to indicate the image encoding (e.g. "gif" or "jpg").
    but, basically, you aren't doing anything "wrong".
    Edited by: jtahlborn on Feb 26, 2008 2:31 PM

  • Help - Inserting an XML document into a Oracle 8i Column (CLOB Type)

    Hi JavaGurus,
    I am looking for a simple java code which will take my XML document as input and insert the same into a Oracle 8i database's column which is of type CLOB.
    Insert statement won't work and I can not use SQL Loader.
    Any one?
    JK

    Maybe you can adapt some of the code in Oracle's "LOB Datatype" example, which is a complete working program that stores and retrieves BLOBs and CLOBs.
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html

  • Big XML document as blob in firebird database

    Hi! I'm having some problems trying to use blob to store an XML document on a Firebird database. I'll try to make this simple: I'm reading a CD and copying the structure to an xml document (org.w3c.dom.Document), and i need to store it on a firebid database. The thing is that the document is really huge and when i try to insert it as text i get an exception:
    org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544726. Error reading data from the connection.
    Reason: Error reading data from the connection.
    Here is the code to insert:
    StringBuffer buffer = new StringBuffer();
            printDOM(catalog.getXMLDom(), buffer);
            new DBInsert("INSERT INTO CD (NAME, CATEGORY, CATALOG_TYPE, CATALOG_DESCRIPTION, CATALOG_UBICATION, CATALOG_FORMAT, XML) VALUES ('" + catalog.getName() + "','" + category + "','" + catalog.getCatalogType() + "','" + catalog.getCatalogDescription() + "','" + catalog.getCatalogUbication() + "','" + catalog.getCatalogFormat() + "','" + buffer.toString() + "')"); The buffer has all the xml structure which i took from the Document object, and when i read from the database it's supposed to restore the document from the xml structure.
    I'd be very happy if someone gives me a clue with that :) I have no idea how to insert and how to read the blob. The database column is defined with this domain CREATE DOMAIN BXML AS
    BLOB SUB_TYPE 1 SEGMENT SIZE 4096 CHARACTER SET NONE;
    Thanks for your time!
    Fede
    Edited by: fedebobbio1 on Dec 5, 2007 6:24 PM

    See the document demo for the XSQL Servlet.
    If it inserts an xml document into the database as a blob.

  • How to insert data into a table from an xml document

    using the XmlSql Utility, how do I insert data into a table from an xml document, using the sqlplus prompt.
    if i use the xmlgen.insertXML(....)
    requires a CLOB file, which i dont have, only the xml doc.
    Cant i insert directly from the doc to the table?
    the xmlgen examples I have seen first convert a table to a CLOB xmlString and then insert it into another table.
    Isnt there any other way?

    Your question is little perplexing.
    If you're using XML SQL Utility from
    the commandline, just use putXML.
    java OracleXML putXML
    null

  • How do I add (or insert) a node into an XML document with JSTL?

    Dear all,
    I am trying to use JSTL to store some data from a form into XML. However, I have read many articles in JSTL and only found that it can only be, as far as those articles are concerned, used to "read" data from XML files, but not "write" to them.
    Am I missing something in JSTL? Or, if I want to write to an XML file (e.g., insert a new node, or modify a node's data), will I have to write my own bean and then use <c:usebean />?
    Thanks very much in advance.
    Regards,
    Robert

    JSTL is not a programming language in and of itself. It is intended to help you to write scriptlet free JSPs.
    JSP pages (by one school of thought) are intended to function as the "View" in a Model-View-Controller architecture.
    Being a view, JSP pages should be able to look at things - but not touch.
    The standard pattern is to go to a servlet first, which invokes the logic, and then forwards to a JSP for rendering.
    Editing XML by adding new nodes etc etc is thus a function of the java code layer - servlet/action whatever you want to call it.
    Giving you the power to edit XML documents via JSTL (ie on a JSP page) takes away from purity of the MVC design.
    Hence why they don't provide the tags for manipulating XML, and only provide the database tags with a disclaimer that they should only be used for prototypes/trivial apps!
    JSTL is designed to replace scriptlet code on a JSP page.
    It can replace 99% of scriptlet code. The other 1% shouldn't be on the JSP in the first place :-)
    cheers,
    evnafets

  • Want to load an xml document directly into an Oracle table

    From the Oracle XML Applications book pg: 106/107
    there is an example where it inserts into a Oracle table from the xml_documents table. What I would like to do is insert directly from the xml document and was able to but not able to get rid of the inserting into xml_documents section.
    CREATE OR REPLACE PROCEDURE insertXmlFile( dir VARCHAR2,
    file VARCHAR2,
    myTable varchar2,
    name VARCHAR2 := NULL) IS
    theBFile BFILE;
    theCLob CLOB;
    theDocName VARCHAR2(200) := NVL(name,file);
    BEGIN
    -- (1) Insert a new row into xml_documents with an empty CLOB, and
    -- (2) Retrieve the empty CLOB into a variable with RETURNING..INTO
    INSERT INTO xml_documents(XML_DOCUMENT_NM,XML_DOCUMENT_TX)
    VALUES('DELETE ME',empty_clob())
    RETURNING XML_DOCUMENT_TX INTO theCLob;
    -- (3) Get a BFile handle to the external file
    theBFile := BFileName(dir,file);
    -- (4) Open the file
    dbms_lob.fileOpen(theBFile);
    -- (5) Copy the contents of the BFile into the empty CLOB
    dbms_lob.loadFromFile(dest_lob => theCLob,
    src_lob => theBFile,
    amount => dbms_lob.getLength(theBFile));
    -- (5a) Insert the rows into the proper table
    insProc(theClob, myTable);
    -- (6) Close the file and commit
    dbms_lob.fileClose(theBFile);
    delete from xml_documents
    where xml_document_nm = 'DELETE ME';
    COMMIT;
    END;
    execute insertXmlFile ('XMLFILES','emp.xml','emp')

    Yes I would like to insert directly from an emp.xml file and load it directly into an emp table and not have to load the document in the xml_documents table and then insert into the emp table like I am doing in this procedure.

  • Loading a XML-document into tables

    Hi,
    I have created a view for the tables below.
    Table Book with columns:
    - Book_ID
    - Book_Name
    - Ref_To_Price ( -> is a reference to Table Price (Price_ID))
    Table Price with columns:
    - Price_ID
    - Price_DM
    SQL-Syntax:
    "create view Bookprice as select Book_ID, Book_Name, Ref_To_Price, Price_ID, Price_DM from Book, Price where Ref_To_Price = Price_ID; "
    XML-Document:
    <?xml version="1.0" encoding="UTF-16"?>
    <!DOCTYPE ANWENDUNGEN SYSTEM "file:/E:/book.dtd">
    <!-- ?xml-stylesheet href="book.xsl" type="text/xsl"? -->
    <ROOTDOC>
    <ROW>
    <BOOK_ID>66-77</BOOK_ID>
    <BOOK_NAME>JavaScript</BOOK_NAME>
    <REF_TO_PRICE>12</REF_TO_PRICE>
    <PRICE_ID>12</PRICE_ID>
    <PRICE_DM>25.50DM</PPRICE_DM>
    </ROW>
    </ROOTDOC>
    If I use the XML SQL Utility to insert the XML-Document, the following error message came up:
    " Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: java.sql.SQLException: ORA-01776: cannot modify more than one base table through a join view "
    Can anyone help me, please ?
    null

    Hi,
    This is a classic join view problem, where u cannot update two tables in one shot. The main problem is that ur two tables are not normalized correctly. Why can't they be in just one table?
    OK, if that is not possible, then the best way out is to create a simple INSTEAD OF trigger on the view which will insert correclty,
    e.g.
    CREATE TRIGGER bookprice_tr INSTEAD OF INSERT ON Bookprice FOR EACH ROW
    BEGIN
    insert into Book values (:NEW.Book_id,
    :NEW.Book_name, :NEW.Ref_to_Price);
    insert into Price
    values(:NEW.Price_ID, :NEW.Price_DM);
    END;
    Hope this helps,
    Murali

  • Inserting an element into an XML document

    I am simply looking insert a new element into an existing XML Document using JDOM. Here is my code so far:
    public class UserDocumentWriter {
         private SAXBuilder builder;
         private Document document;
         private File file = new File("/path/to/file/users.xml");
         private Element rootElement;
         public UserDocumentWriter() {
              builder = new SAXBuilder();
              try {
                   document = builder.build(file);
                   rootElement = document.getRootElement();
              } catch (IOException ioe) {
                   System.err.println("ERROR: Could not build the XML file.");
              } catch (JDOMException jde) {
                   System.err.println("ERROR: " + file.toString() + " is not well-formed.");
         public void addContact(String address, String contact) {
              List contactList = null;
              Element contactListElement;
              Element newContactElement = new Element("contact");
              newContactElement.setText(contact);
              List rootsChildren = rootElement.getChildren();
              Iterator iterator = rootsChildren.iterator();
              while (iterator.hasNext()) {
                   Element e = (Element) iterator.next();
                   if (e.getAttributeValue("address").equals(address)) {
                        contactListElement = e.getChild("contactlist");
                        contactListElement.addContent(newContactElement);
                        writeDocument(document);
         public void writeDocument(Document doc) {
              try {
                   XMLOutputter output = new XMLOutputter();
                   OutputStream out = new FileOutputStream(file);
                   output.output(doc, out);
              } catch (FileNotFoundException ntfe) {
                   System.err.println("ERROR: Output file not found.");
              } catch (IOException ioe) {
                   System.err.println("Could not output document changes.");
         }However, the problem is, the newly added element will always be appended to the end of the last line, resulting in the following:
    <contactlist>
                <contact>[email protected]</contact><contact>[email protected]</contact></contactlist>Is there anyway in which I can have the newly added element create it's own line for the purpose of tidy XML? Alternatively is there a better methodology to do the above entirely?

    Your question is not very clear.
    Do you want to know How to insert an element into an XML document?
    Answer: I can see you already know how to do it. You have added the element using addContent()
    or do you want to know How to display the XML in a tidy format?
    Answer: to view the XML in a properly formatted style you can you the Format class. A very basic way of viewing the XML would be:
       * Prints the Document to the specified file.
       * @param doc
       * @param filename
       * @param formatting
      public static void printDocToFile(Document doc, String strFileName,
          boolean formatting)
        XMLOutputter xmlOut = null;
        if (!formatting)
          xmlOut = new XMLOutputter();
        } else
          Format prettyFormat = Format.getPrettyFormat();
          prettyFormat.setOmitEncoding(false);
          prettyFormat.setOmitDeclaration(false);
          xmlOut = new XMLOutputter(prettyFormat);
        try
          if (doc != null)
            FileWriter writer = new java.io.FileWriter(strFileName, true);
            xmlOut.output(doc, writer);
            writer.flush();
            writer.close();
          } else
            System.out.println("Document is null.");
        catch (Exception ex)
          System.out.println(ex);
      }

  • Inserting XML document into XDB fails with can't convert to OPAQUE

    Hi,
    When I try to insert a document using oracle 9.2.0.5 client software into a 9.2.0.5 database, with the following code:
    void insertDocument(String document) {
    XMLType xt = XMLType.createXML(connection, document);
    PreparedStatement ps = connection.prepareStatement("insert into xmldocuments values(?)");
    ps.setObject(1, xt);
    ps.executeUpdate();
    The setObject function always throws an exception (after a very long time) with:
    java.sql.SQLException: Fail to convert to internal representation: OPAQUE()
    This also fails when we use the InputStream and org.w3c.xml.Document variants.
    We use the OCI driver, otherwise we get errors retrieving the documents from XMLDB.
    What is going wrong here?

    David,
    If you search through the historical data in this list there are previous post regarding opaque.
    These may be useful. Possibly your reaching the size limit.

  • How to split XML document into two

    I want to create new docuemnt by taking part of the existent XML document under the node document_text
    vNodeList := xmldom.getElementsByTagName(vdoc, 'document_text');
    vNode := xmldom.item(vNodeList, 0); -- The xmldom.getNodeName(vNode) of this node is exactly what i am
    -- looking for
    vdoc:= xmldom.makeDocument( vNode);
    insert into cltab values (empty_clob()) returning cl into cl;
    xmldom.writeToClob(vdoc_txt, cl);
    But after that i am still getting the whole document tree, - copy of the whole document.
    What am i doing wrong? What functions should i use for this kind of task? xmldom.clonenode?
    Could you recommend any good description of the xmldom package?
    Thanks,
    Roman

    If you are using an FI  entry F-43 to generate invoice this can be done by giving the same invoice ref. in the Inv. Ref. field  for two vendors. This is manual
    Document Split will split the document between two profit center and not between vendors.

  • How to get an xml string into a Document w/o escaping mark-up characters?

    Hi,
    I am using one of the latest xerces using Java. I am pretty sure I am using xerces-2.
    I have an existing Document and I am trying to add more content to it. The new content itself is xml string. I am trying to insert this xml string into the document using document.createTextNode. I am able to insert, but somewhere it is escaping the mark-up characters (<,>,etc). When I convert the document into String, I can see, for example, <userData> instead of <userData>.
    There is an alternative option to accomplish this by creating a new document with this xml string, get the root element, import this element into my document. Execution time for this procedure is very high - means, this is very bad in terms of time-wise performance.
    Can any help on how to accomplish this (bringing an xml string into a document without escaping mark-up characters) in time-efficient way.

    So you want to treat the contents of the string as XML rather than as text? Then you have to parse it.
    Or if your reason for asking is just that you don't like the look of escaped text, then use a CDATA section to contain the text.

  • To load an XML document into 40 tables

    How do I load a large XML document into 40 tables. Most of the exmaples, I see only load one table into the Orcale database?

    From the above document:
    Storing XML Data Across Tables
    Question
    Can XML- SQL Utility store XML data across tables?
    Answer
    Currently XML-SQL Utility (XSU) can only store to a single table. It maps a canonical representation of an XML document into any table/view. But of course there is a way to store XML with the XSU across table. One can do this using XSLT to transform any document into multiple documents and insert them separately. Another way is to define views over multiple tables (object views if needed) and then do the inserts ... into the view. If the view is inherently non-updatable (because of complex joins, ...), then one can use INSTEAD-OF triggers over the views to do the inserts.
    -- I've tried this, works fine.

  • Parsing XML document with nested elements into multiple db tables(master-detail)

    Can you help me with storing xml document into master-detail tables?
    I have two tables:
    1) customers (customerid number primary key, firstname varchar2(30),lastname varchar2(30))
    2) cust_addresses (customerid number references customers, street varchar2(30),city varchar2(30),state varchar2(10),zip varchar2(10))
    I have XML document:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW num="1">
    <CUSTOMERID>1044</CUSTOMERID>
    <FIRSTNAME>Paul</FIRSTNAME>
    <LASTNAME>Astoria</LASTNAME>
    <HOMEADDRESS>
    <STREET>123 Cherry Lane</STREET>
    <CITY>SF</CITY>
    <STATE>CA</STATE>
    <ZIP>94132</ZIP>
    </HOMEADDRESS>
    <HOMEADDRESS>
    <STREET>N.Fryda 4</STREET>
    <CITY>CB</CITY>
    <STATE>CZ</STATE>
    <ZIP>37005</ZIP>
    </HOMEADDRESS>
    </ROW>
    </ROWSET>
    I know that I must use DBSM_XMLSave package, create view and instead of trigger but I did found no example in documentation.
    Thanx.

    Interested question; one I do not know the answer to at the moment, I am afraid. I would like to know your results.
    To tell others, though, what I have done. I did finally adapt Muench's not-yet-published examples #71 to work with a table. Here the table has as it's value "#{backing_app_EPG_DAYPG.jobDayDriverTable[row.Id1]}"
    This accesses a hash map defined in the backing bean as follows:
    public Map jobDayDriverTable = new HashMap(){
    @Override
    public Object get(Object key) {
    Number jobDayId = (Number)key;
    if (getEpgDayPage().jobDayDrivers(jobDayId) != null) {
    return getEpgDayPage().jobDayDrivers(jobDayId).getAllRowsInRange();
    else return null;
    jobDayDrivers returns RowIterator. From this I call getAllRowsInRange which returns a Row[]. The table consumes this as a value, and lists the values as I want.
    Since the table is using Rows for its rows, I am guessing that it would have access to #{row.rowKeyStr}, or at least #{row.<pk>} which would allow you to programmatically set the current row using code like the following:
    public static boolean setCurrentRow() {
    // BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    // bindings.getOperationBinding("setCurrentRowWithKey");
    (OperationBinding)EL.get("#{bindings.setCurrentRowWithKey}");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return false;
    return true;
    You could call this as part of code in a pages backing bean behind a button or link.
    Hope this helps somebody.
    By the way example #71 was to get a detail set of rows from a master row value and display the detail set in the master row of an af:table.
    You can find this and other examples at http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html

Maybe you are looking for