Converting a RenderedOp to a BLOB

Hi
I have a database which stores images as BLOBS, I have no problem storing the images when I have the image file initially, however when I load the BLOB from the database to my Java application I allow people to modify the image which is converted to a RenderedOp, I want to be able to save this manipulated image to the database but obviously have no filename for the image, I was wondering is it possible to store this RenderedOp as a BLOB and if so how to do so?
Cheers
Richie

BLOBS are a bit of a nightmare in JDBC. The Blob interface looks like it was designed by someone who didn't know what BLOBs are. In particular there's no method of creating a new java.sql.Blob, you can only retrive one from a database query.
What I do for Postgress is to write my own implementation of java.sql.Blob which reads from a file when the driver does a getBinaryStream on it. Then setBlob on a PreparedStatement seems to store OK, at least on Postgress creating a new record.
This is my "fake" Blob
* FileBlob.java
* Created on 06 April 2004, 09:00
package org.figis.util;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.SQLException;
* <p>{@link java.sql.Blob} object for inserting new BLOB into database from file.</p>
* <p>This, to my mind, is a fairly ugly fudge to get arround the complete
* ommision of a capability from JDBC. The alternative, in the case of Postgres,
* is to access a proprietary interface.<p>
* <p>When an instance of this class is supplied to a {@link java.sql.PreparedStatement}
* Postgres (at least) creates a new Blob and copies the stream obtained from getBinaryStream()
* into it, then it puts the BLOB reference into the SQL.<p>
* <p>This might, or might not work with other databases.</p>
* @version $Id: FileBlob.java,v 1.3 2004/07/28 16:49:00 malcolmm Exp $
* @see java.sql.Blob
   @see java.sql.PreparedStatement
* @author  malcolm
public class FileBlob implements Blob {
    InputStream stream;
    long size;
     * Creates a new instance of FileBlob
     * @param stream Input stream with data
     * @param size Length of data
    public FileBlob(InputStream stream, long size) {
        this.stream = stream;
        this.size = size;
     * Create a new instance of FileBlob from a File object
     * @param file The existing file to copy
     * @throws IOException if file cannot be openned.
    public FileBlob(java.io.File file) throws java.io.IOException {
        this(new java.io.FileInputStream(file), file.length());
    /** Gets a stream containing the file data.
     * @throws SQLException Wrapped IO exception should file be duff
     * @return An inputStream
    public InputStream getBinaryStream() throws SQLException {
        return stream;
    /** Unsupported
     * @param pos start position
     * @param length bytes to read
     * @throws SQLException On read error
     * @return byte array
    public byte[] getBytes(long pos, int length) throws SQLException {
        throw new UnsupportedOperationException("getBytes");
    /** Get size of input data
     * @throws SQLException Retrieval error
     * @return Size in bytes
    public long length() throws SQLException {
        return size;
    /** Unsupported
     * @param pattern Pattern to find
     * @param start search start
     * @throws SQLException On access error
     * @return position
    public long position(byte[] pattern, long start) throws SQLException {
        throw new UnsupportedOperationException("position");
    public long position(Blob pattern, long start) throws SQLException {
        throw new UnsupportedOperationException("position");
    public java.io.OutputStream setBinaryStream(long pos) throws SQLException {
        throw new UnsupportedOperationException("setBinaryStream");
    public int setBytes(long pos, byte[] bytes) throws SQLException {
        throw new UnsupportedOperationException("setBytes");
    public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
        throw new UnsupportedOperationException("setBytes");
    public void truncate(long len) throws SQLException {
        throw new UnsupportedOperationException("truncate");

Similar Messages

  • Converting CHAR or CLOB to BLOB in Oracle9i

    Hi!
    I want to convert CHAR or CLOB to BLOB.
    I am working with Oracle9i Database.
    Oracle9i Supplied PL/SQL Package Release 2 (9.2) does'nt support DBMS_LOB.CONVERTTOBLOB procedure.
    How I can convert CHAR or CLOB to BLOB in Oracle9i?
    Valery

    Hi Valery,
    For conversion to blob, just try the utl_raw package.
    I use utl_raw.cast_to_raw quite often.
    Or have a look at:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:437819871174
    Good luck,
    Jan-Marcel

  • Converting an image as a blob content from .gif format to .jpg format

    Hi
    Does anyone know how to convert a blob content from .gif format to .jpg format?
    I've tried looking at the process-method of intermedia, but I can't figure out how it's supposed to work... I'm on a 10.2.0.2 standard edition database
    I simply have a blob containing a gif-image, and I want it to be convertet to a jpg-image for further use
    Can anyone help?
    Thank you
    /Klaus Mogensen

    Hi
    Does anyone know how to convert a blob content from
    .gif format to .jpg format?
    I've tried looking at the process-method of
    intermedia, but I can't figure out how it's supposed
    to work... I'm on a 10.2.0.2 standard edition
    database
    I simply have a blob containing a gif-image, and I
    want it to be convertet to a jpg-image for further
    useWhat OS is the database running on? If it is a *nix flavour, you can call out to image magick convert utility (it is pre-installed on most linux variants, and you can compile it from source for other unixes). So you would probably store the blob into a temp file on the database server, call out to the shell to execute convert, and then load a blob from the converted file. See http://imagemagick.org for more information.
    If that is not an option, you might be able to use Java Advanced Imaging API from a Java stored proc to convert between those image formats. See http://java.sun.com/products/java-media/jai/downloads/download-1_1_2.html
    gojko adzic
    http://gojko.net

  • Limitation of converting from Long Raw to Blob

    Hi All,
    DB:11g
    Oracle Apps:R12
    Is there a limitation of converting from Long Raw to Blob?
    Please share your experience on this subject in case anyone has faced it before.
    Thanks for your time!
    Regards,

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:13213885403654
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:510622111991

  • Need to convert the binary data in blob field to readable format

    Hi,
    We need to convert the Binary data in the BLOB field to readable format and need to display it in Oracle Apps Environment,does anybody come across the similar requirement.
    please advise, thanks in advance.
    Regards,
    Babu.

    You could use standard Attachments functionality here ... if the blob is not in FND_LOBS, insert into FND_LOBS, fnd_attached_documents etc to enable viewing via "Attachments" to the entity the blob is related to.
    Gareth

  • Converting datatype from Varchar2 to BLOB ...how..???

    Hi i have to convert the datatype of a varchar2 column in one of my tables to BLOB...and i also have to preserve the data existing in the column in the process.
    Please guide .
    Thanks.

    first of all, I don't think that BLOB and VARCHAR2 are compatible, logically that is. BLOB is binary and VARCHAR2 is mere text.
    The way I'd do it is to have all the VARCHAR2 saved into text files and then stored in BLOB. Here is a hint:
    let's call your VARCHAR2 column 'X'
    1- create a new column in the table of type BLOB and call it 'Y'.
    2- using pl/sql text I/O, save each VARCHAR2 in a text file using the primary key of the table as file name.
    3- upload each file back to the table in it's corresponding record in column 'Y'.
    4- update the table setting 'X' in each table to NULL.
    5- alter table to delete column 'X'.
    6- alter table to rename 'Y' ---> 'X'
    finally, before doing any of these steps make sure you have enough disk space and that you really know how to deal with BLOB's as they need special insert and update commands.
    hope that helped
    Nasser Asiri

  • Convert a column from CLOB to BLOB

    hi,
    I recently had a requirement to save a XML file in Database. Presently the column is of datatype CLOB. But since CLOB has asize limitation, when iam saving a file of larger size it is throwing exception.
    So iam planning to convert this CLOB column to BLOB.
    Is this a right approach??

    798116 wrote:
    hi,
    I recently had a requirement to save a XML file in Database. Presently the column is of datatype CLOB. But since CLOB has asize limitation, when iam saving a file of larger size it is throwing exception.
    So iam planning to convert this CLOB column to BLOB.
    Is this a right approach??I'd be very concerned if you're creating XML that exceeds the limits of a CLOB column. That would smell of bad design somewhere.
    Character based data such as XML, would be better placed in a CLOB than a BLOB, as a BLOB is primarily for storing binary data, not character data.
    The best however would be to store your XML in an XMLTYPE datatype, which is based on CLOB, as that offers XML methods around it.

  • ORDSYS.ORDimage and BLOB convertion

    Hi every one,
    I have a ORDSYS.ORDimage in a table (under Oracle 9i) that I need to show in a Forms 6i Image item (wich is finally a BLOB I guess).
    Is there anyone that could tell me how to convert ORDSYS.ORDimage into a BLOB. I found in the interMedia documentation examples on how to save a BLOB into a ORDSYS.ORDimage with the filename of the image but I found nothing on converting ORDSYS.ORDimage into BLOB and vice versa.
    Thank everyone for your help.
    Marc

    And you are possible to display blob from table in form s image item?
    I tried this, but it didn't go, can you tell me, how did you do?

  • Download clob contents from function instead of a blob column in a table

    I found some examples how to create a download link for data stored in a blob column. However my data is not stored in a blob column but is created in a function returning a clob. Obviously this function can be used to fill a blob column that can then be downloaded but maybe there is a more direct route.

    Hello Rene,
    I adapted one of my snippets for download-links for your case. The procedure is pretty much the same like the one concerning an existing blob. To provide the download, you need to convert your clob into a blob, which can be done easily by using the corresponding function provided by the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm]DBMS_LOB-API.
    The result might look like the following (untested) code snippet:
    CREATE OR REPLACE procedure download_from_function (p_func_argument IN VARCHAR2, p_filename IN VARCHAR2)
    AS
      l_http_response  UTL_HTTP.resp;
      l_blob           BLOB;
      l_raw            RAW(32767);
      l_length         INTEGER;
      l_dest_offset    INTEGER := 1;
      l_src_offset     INTEGER := 1;
      l_lang_context   INTGER := DBMS_LOB.DEFAULT_LANG_CTX;
      l_warning        INTEGER;
    BEGIN
      -- Initialize the BLOB.
      DBMS_LOB.createtemporary(l_blob, FALSE);
      -- replace the function call for src_clob
      DBMS_LOB.convertToBlob( dest_lob     => l_blob,
                              src_clob     => your_clob_function(p_func_argument),
                              amount       => DBMS_LOB.LOBMAXSIZE,
                              dest_offset  => l_dest_offset,
                              src_offset   => l_src_offset,
                              blob_csid    => DBMS_LOB.DEFAULT_CSID,
                              lang_context => l_lang_context,
                              warning      => l_warning);
      l_length := DBMS_LOB.getlength(l_blob);
      -- create response header
      OWA_UTIL.mime_header('text/plain', false);
      -- add furhter header attributes
      htp.p('Content-length: ' || l_length);
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- close the headers
      OWA_UTIL.http_header_close;
      -- download the BLOB
      WPG_DOCLOAD.download_file( l_blob );
      -- release BLOB from memory
      DBMS_LOB.freetemporary(l_blob);
    EXCEPTION
      WHEN OTHERS THEN
        DBMS_LOB.freetemporary(l_blob);
        RAISE;
    END download_from_function;
    -- Page process before header on blank page
    BEGIN
      download_from_function (p_func_argument => 'your_argument_for_your_clob_returning_function',
                              p_filename => 'filename_for_download.txt');
    END;You should change function name and arguments to fit your clob-function's signature. You may also want to add a characterset conversion if needed. See the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm]API-doc for details.
    -Udo

  • Blob to Clob

    Hi All,
    Any help with be much appreciated.
    I wrote the following but keep getting the following error: ORA-06502: PL/SQL: numeric or value error. I know the flex_ws_api.blob2clobbase64 function is working as I have tested it outside of the application but when I try to push it to a page item I get the error, the function is converting a document form a blob to a clob.
    declare
    l_blob BLOB;
    l_return CLOB;
    BEGIN
    select blob_content into l_blob
    from wwv_flow_files
    where name = :P169_FILENAME;
    l_return := flex_ws_api.blob2clobbase64(l_blob);
    :P169_CLOB_VALUE := l_return;
    END;

    user10256482 wrote:
    :P169_CLOB_VALUE defined as just a textarea item and the error I receive is in the Application (APEX) so I dont get a line number.I'm thinking :p169_clob_value was defined with insufficient length and the clob is too long to fit into it

  • BLOB-- CLOB-- BLOB conversion reducing length of BLOB

    Hi,
    I am using the following BLOB-->CLOB and CLOB-->BLOB conversion functions :
    CREATE OR REPLACE FUNCTION blob_to_clob (blob_in IN BLOB)
    RETURN CLOB
    AS
         v_clob CLOB;
         v_varchar RAW(32001);
         v_varchar1 VARCHAR2(32001);
         v_start     INTEGER := 1;
         v_buffer INTEGER := 32001;
    BEGIN
         DBMS_LOB.CREATETEMPORARY(v_clob, TRUE);
         FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(blob_in) / v_buffer)
         LOOP
         DBMS_LOB.READ(blob_in,v_buffer,v_start,v_varchar);
    DBMS_LOB.WRITEAPPEND(v_clob, utl_raw.length(v_varchar), v_varchar);
         v_start := v_start + v_buffer;
         END LOOP;
    RETURN v_clob;
    END blob_to_clob;
    CREATE OR REPLACE FUNCTION clob_to_blob (clob_in IN CLOB)
    RETURN BLOB
    AS
         v_blob BLOB;
         v_varchar RAW(32001);
         v_varchar1 RAW(32001);
         v_start     INTEGER := 1;
         v_buffer INTEGER := 32001;
    BEGIN
         DBMS_LOB.CREATETEMPORARY(v_blob, TRUE);
         FOR i IN 1..CEIL(DBMS_LOB.GETLENGTH(clob_in) / v_buffer)
         LOOP
         DBMS_LOB.READ(clob_in,v_buffer,v_start,v_varchar);
    DBMS_LOB.WRITEAPPEND(v_blob, utl_raw.length(v_varchar), v_varchar);
              v_start := v_start + v_buffer;
         END LOOP;
    RETURN v_blob;
    END clob_to_blob;
    I am using these functions to convert image files, stored as BLOB to CLOB for intermediate storage, and then converting them back to BLOB. In this process, I see a loss of information when the image is converted from CLOB to BLOB ...which is seen by using dbms_lob.getlength() .Using the following sql query:
    select dbms_lob.getlength(file_body),
    dbms_lob.getlength(blob_to_clob(file_body)),
         dbms_lob.getlength(clob_to_blob(blob_to_clob(file_body)))
    from my_table where image_id in (8819)
    i see that returned length is usually half in the 3rd column, i.e. for dbms_lob.getlength(clob_to_blob(blob_to_clob(file_body))). There is no change in length for 1st and 2nd columns. Could you please let me know why length is getting lost in the CLOB to BLOB conversion ? Thanks.

    Thanks for replying.
    This is required because we have to store images in ldt files using FNDLOAD, whiich only supports CLOB, not BLOB. I understand that images stored in binary formats should be stored in BLOB only, but I am exploring the possibility of converting BLOB format to CLOB and then back to BLOB without loss of information. Any pointers in this regard are appreciated. Thanks !

  • How to read a BLOB (base64 - stream) from XML-file in ORACLE10

    ORACLE 10g
    PL/SQL function
    MY XML-file:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <slo xmlns="http://www.example.org/detection">
         <LekKey>1999_036371_509627</LekKey>
         <HuiNum>46</HuiNum>
         <Res></Res>
         <InfLig>TEST STRUI AFGESTORVEN - PLAANSTRAAT 46</InfLig>
         <XWGS>3.637028</XWGS>
         <YWGS>50.962667</YWGS>
         <Pei>EANDIS</Pei>
         <DatPei>1999-11-30T10:17:36.000+01:00</DatPei>
         <Kan> </Kan>
         <Doc>UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAA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RvbVhtbC9pdGVtUHJvcHMxLnhtbFBLAQItABQABgAIAAAAIQD+hDirOAIAAMwHAAASAAAA
    AAAAAAAAAAAAADA4CQB3b3JkL2ZvbnRUYWJsZS54bWxQSwECLQAUAAYACAAAACEAp/3kQ44BAADeAgAA
    EQAAAAAAAAAAAAAAAACYOgkAZG9jUHJvcHMvY29yZS54bWxQSwECLQAUAAYACAAAACEAqchcqowAAADa
    AAAAEwAAAAAAAAAAAAAAAABdPQkAY3VzdG9tWG1sL2l0ZW0xLnhtbFBLAQItABQABgAIAAAAIQBgX/2I
    CwEAALoBAAAUAAAAAAAAAAAAAAAAAEI+CQB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAA
    IQDQwaCR/gEAAGgEAAAQAAAAAAAAAAAAAAAAAH8/CQBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAASABIA
    pQQAALNCCQAAAA==</Doc>
    </slo>
    I have to write an PL/SQL function where I can read all the data in the XML-file (see attach).
    In this XML there is a BLOB stored (base64 - stream -> that contains always a MSWORD document).
    1) how can I extract this BLOB + the other data in the XML and save this data in a ORACLE table?
    2) how can I decode this BLOB and save this MSWORD-document to a fileserver?

    First extract your data as CLOB (as it's character based)...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select xmltype('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      2  <slo xmlns="http://www.example.org/detection">
      3    <LekKey>1999_036371_509627</LekKey>
      4    <HuiNum>46</HuiNum>
      5    <Res></Res>
      6    <InfLig>TEST STRUI AFGESTORVEN - PLAANSTRAAT 46</InfLig>
      7    <XWGS>3.637028</XWGS>
      8    <YWGS>50.962667</YWGS>
      9    <Pei>EANDIS</Pei>
    10    <DatPei>1999-11-30T10:17:36.000+01:00</DatPei>
    11    <Kan> </Kan>
    12    <Doc>UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAA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H2ynJ818kMhAH/uQhy4LpLUFPFj6VRIb3l0RbMn/M7Q8b1vQfKvHz8RhmbHVRmILO64GRHxQ+4g877Vy7ODxkXnUwj1c//k0F1vko0ZaHgJzdW1hj8TfGUZPPWqCeLCB
    7J6HX/+OZpckbWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAADqNAkAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhANouSfniAAAAVQEAABgAAAAAAAAAAAAAAAAA8DYJAGN1c3RvbVhtbC9pdGVtUHJvcHMxLnhtbFBLAQItABQABgAIAAAAIQD+hDirOAIAAMwHAAASAAAAAAAA
    AAAAAAAAADA4CQB3b3JkL2ZvbnRUYWJsZS54bWxQSwECLQAUAAYACAAAACEAp/3kQ44BAADeAgAAEQAAAAAAAAAAAAAAAACYOgkAZG9jUHJvcHMvY29yZS54bWxQSwECLQAUAAYACAAAACEAqchcqowAAADaAAAAEwAAAAAAAAAAAAAAAABdPQkAY3VzdG9tWG1sL2l0ZW0xLnhtbFBLAQItABQABgAIAAAAIQBgX/2ICwEAALoBAAAUAAAAAAAA
    AAAAAAAAAEI+CQB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQDQwaCR/gEAAGgEAAAQAAAAAAAAAAAAAAAAAH8/CQBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAASABIApQQAALNCCQAAAA==</Doc>
    13  </slo>') as xml from dual)
    14  --
    15  -- end of test data
    16  --
    17  select x.*
    18  from   t
    19        ,xmltable(xmlnamespaces(default 'http://www.example.org/detection'),
    20                  '/slo'
    21                  passing t.xml
    22                  columns lekkey varchar(30) path './LekKey'
    23                         ,doc    clob        path './Doc'
    24*                ) x
    SQL> /
    LEKKEY                         DOC
    1999_036371_509627             UEsDBBQABgAIAAAAIQB5gHbnswEAAHcGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0VUtP20AQviP1P1h7rewNPVRVFYcDj2OL1FTluqzH
                                   ycK+tDMB8u8764AVwMSBiIsle/d7zLc74+nJg7PFHSQ0wdfiuJqIArwOjfGLWvydX5Q/RIGkfKNs8FCL
                                   NaA4mX05ms7XEbBgtMdaLIniTylRL8EprEIEzyttSE4Rv6aFjErfqgXIb5PJd6mDJ/BUUuYQs+kZtGpl
                                   qTh/4M8bJ9EvRHG62ZelamFcxufvchCRwOILiIrRGq2Ia5N3vnnhq3z0VDGy24NLE/ErG39DIa8897Qt
                                   8DbuJg7XchOhK+Y3559MA8WlSvRLOS5W3ofUyCboleOgqt3KA6WFtjUaenxmiyloQOSDdbbqV5wy/qnk
                                   IR96hRTclbPSELjLFCIeH2ynJ818kMhAH/uQhy4LpLUFPFj6VRIb3l0RbMn/M7Q8b1vQfKvHz8RhmbHV
                                   RmILO64GRHxQ+4g877Vy7ODxkXnUwj1c//k0F1vko0ZaHgJzdW1hj8TfGUZPPWqCeLCB7J6HX/+OZpck
                                   bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAADqNAkAY3VzdG9tWG1sL19y
                                   ZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhANouSfniAAAAVQEAABgAAAAAAAAAAAAAAAAA
                                   8DYJAGN1c3RvbVhtbC9pdGVtUHJvcHMxLnhtbFBLAQItABQABgAIAAAAIQD+hDirOAIAAMwHAAASAAAA
                                   AAAAAAAAAAAAADA4CQB3b3JkL2ZvbnRUYWJsZS54bWxQSwECLQAUAAYACAAAACEAp/3kQ44BAADeAgAA
                                   EQAAAAAAAAAAAAAAAACYOgkAZG9jUHJvcHMvY29yZS54bWxQSwECLQAUAAYACAAAACEAqchcqowAAADa
                                   AAAAEwAAAAAAAAAAAAAAAABdPQkAY3VzdG9tWG1sL2l0ZW0xLnhtbFBLAQItABQABgAIAAAAIQBgX/2I
                                   CwEAALoBAAAUAAAAAAAAAAAAAAAAAEI+CQB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAA
                                   IQDQwaCR/gEAAGgEAAAQAAAAAAAAAAAAAAAAAH8/CQBkb2NQcm9wcy9hcHAueG1sUEsFBgAAAAASABIA
                                   pQQAALNCCQAAAA==
    SQL>Then, you can convert the CLOB to a BLOB by doing your base64 decoding.

  • Map oracle 9 BLOB type

    I am trying to map a BLOB database object to a java object using typeconversion with TopLink version 9.0.4.1 (build 040128).
    How do I map a BLOB database type? I tried to map it to oracle.sql.BLOB object in my class, (private BLOB m_blobField) but I get an error message:
    Local Exception Stack:
    Exception [TOPLINK-3001] (OracleAS TopLink - 10g (9.0.4.1) (Build 040128)): oracle.toplink.exceptions.ConversionException
    Exception Description: The object [[B@1bdc9d8], of class [class [B], could not be converted to [class oracle.sql.BLOB].
         at oracle.toplink.exceptions.ConversionException.couldNotBeConverted(ConversionException.java:35)
         at oracle.toplink.internal.helper.ConversionManager.convertObject(ConversionManager.java:154)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.convertObject(DatabasePlatform.java:562)
         at oracle.toplink.mappings.DirectToFieldMapping.getAttributeValue(DirectToFieldMapping.java:224)
         at oracle.toplink.mappings.TypeConversionMapping.getAttributeValue(TypeConversionMapping.java:41)
         at oracle.toplink.mappings.DirectToFieldMapping.valueFromRow(DirectToFieldMapping.java:458)
         at oracle.toplink.mappings.DatabaseMapping.readFromRowIntoObject(DatabaseMapping.java:860)
         at oracle.toplink.internal.descriptors.ObjectBuilder.buildAttributesIntoObject(ObjectBuilder.java:164)
         at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:322)
         at oracle.toplink.internal.descriptors.ObjectBuilder.buildObjectsInto(ObjectBuilder.java:380)
         at oracle.toplink.internal.queryframework.DatabaseQueryMechanism.buildObjectsFromRows(DatabaseQueryMechanism.java:146)
         at oracle.toplink.queryframework.ReadAllQuery.execute(ReadAllQuery.java:425)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:493)
         at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1958)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1086)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1038)
         at oracle.toplink.publicinterface.Session.readAllObjects(Session.java:2372)
         at com.starhometest.Tests.RunTest.testBlob(RunTest.java:158)
         at com.starhometest.Tests.RunTest.main(RunTest.java:59)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
    Exception in thread "main"
    Trying to map it to the Blob interface also doesn't work.
    Can anyone help?

    BLOB should be mapped to a byte array using TypeConversionMapping with a target type java.sql.Blob. Also Oracle8Platform or Oracle9Platform should be used.
    For more details please see http://www.oracle.com/technology/products/ias/toplink/technical/tips/LOB/index.html

  • Conversion of BLOB datatype to CLOB datatype

    Hi,
    I would need to convert the column datatype from BLOB to CLOB. currently in the table, the BLOB column has the data. the requirement is to convert this column from BLOB to CLOB datatype.
    please help me how to convert from BLOB datatype to CLOB datatype
    Thanks
    Hari.

    I have just been dealing with the same issue -- mass conversion of data in BLOB form to CLOB. I think I've finally got it working well. I have a table that has an key column then both a BLOB and a CLOB column. I load the BLOBS into the table then run the following PLSQL block (uses the given proc) to transfer the data from the BLOB column to the CLOB column.
    -- Proc to convert BLOB to CLOB
    create or replace function stg.blob_to_clob( p_blb in blob )  return clob  is
       v_clb   clob    ;
       v_dst   integer := 1 ;
       v_src   integer := 1 ;
       v_wrn   integer ;
       v_lng   integer := dbms_lob.default_lang_ctx ;
    begin
       dbms_lob.createtemporary ( v_clb, false ) ;
       dbms_lob.converttoclob
         ( dest_lob      =>  v_clb
         , src_blob      =>  p_blb
         , amount        =>  dbms_lob.lobmaxsize
         , dest_offset   =>  v_dst
         , src_offset    =>  v_src
         , blob_csid     =>  dbms_lob.default_csid
         , lang_context  =>  v_lng
         , warning       =>  v_wrn
       if  ( dbms_lob.NO_WARNING != v_wrn )  then
          v_clb := '~~~{ Error: Invalid Character in source BLOB }~~~' ;
       end if ;
       return v_clb ;     
    exception
       when others then
          v_clb := '~~~{ Error: BLOB Conversion Function Failed }~~~' ;
          return v_clb ;
    end ;
    -- Use the proc above to convert each BLOB to a CLOB in the given table.
    declare
       cursor c1 is
          /* Select the BLOBS to be converted. */
          select  id,  m_blob,  m_clob
            from  stg.temp_cnvrt
                  /* Trying to convert NULL BLOBS will result in an error */
           where  dbms_lob.getlength(m_blob) > 0
          for update ;
       v_tmp_clob   clob ;
    begin
       FOR  nxt in c1  LOOP
          v_tmp_clob := stg.blob_to_clob( nxt.m_blob ) ;
          update  stg.temp_cnvrt
             set  m_clob = v_tmp_clob
           where  current of c1 ;  
       END LOOP ;
       commit ;
    end ;

  • Resizing a BLOB

    I have a customer request to convert a number to a BLOB data type, and then
    set the BLOB size to 4 Bytes. It doesn't matter what size the BLOB was
    originally, it always needs to be 4 Bytes. I not sure how to accomplish this.
    Is there a way to resize a BLOB?
    Here is what I have so far...
       declare
            first_num number  := 128117002;
            second_num number := 0;
            x BLOB;
            y BLOB;
          begin
            x := TO_BLOB(UTL_RAW.CAST_FROM_NUMBER(first_num));
            y := TO_BLOB(UTL_RAW.CAST_FROM_NUMBER(second_num));
            dbms_output.put_line(dbms_lob.GETLENGTH(x)); -- returns 6 bytes
            dbms_output.put_line(dbms_lob.GETLENGTH(y)); -- returns 1  byte
            -- now I need someway to convert X and Y to 4 bytes
       end;Any suggestions?

    This does not make sense for me because:
    - if you are sure that you data takes only 4 bytes why using a BLOB ? RAW data type may be easier in this case
    - I may be wrong but I don't think you can tell Oracle to resize a BLOB variable: the BLOB has just the size it needs to have to store its data.

Maybe you are looking for

  • Hoiw do I force my new mf8580cdw to print in black and white only (grey scale)?

    First of all I am using windows 7 - 64bit and my printer is the MF8580CDW. I am using the UFRII print driver. I have tried changing one/all of the profiles in the print settings and printer properties to "black and white" printing but the software ke

  • Want to use FiOS TV via CableCARD - CSR insists I must lease at least one set-top box

    Started looking into subscribing to Verizon using a CableCARD-based tuner, since I don't actually own a TV. I did some research at verizon.com and ran across this page (important parts in bold): CableCARDS A CableCARD is a device that provides access

  • Lost my i-tunes

    Hi I'm new to this and am sure that you have been asked before but I would appreciate anyhelp.  I'll give you the whole story.  I set up my i-tunes a few years ago on my big old computer - it is all cd's that I copied.  I set up a sharing thing with

  • How to create a file on a remote machine using PrintStream

    I want to create an HTML file on a remote machine connect via LAN the path is "\\vineet\akh\" akh is folder where I want to save the HTML file. Now in PrintStream i can give only a local file. Please help how to do it

  • Domain Name & Hosting the Website

    I have made a website for an event I am planning in March. Is there a place on Apple where I can purchase my domain name and host it there? or should I be using another place? I need it to be as cheap as possible...but still be a good place for hosti