Commit a blob field

Hi all
I am using Oracle provider to connect to the oracle. I can load a blob field and save it to a local hard but I cant load a file from hard disk and save it into that blob field. it is appears that there is no problem but no action happend . when I commit data and back to load it, the blob is empty and contains no data.
plz help me if there is something wrong that I do.
I first open the datasource and select that field for update and create a blob stream and then load a file stream into that field then commit.
regards
mohammad

Are u using .Net file streams or Win32 native streams?

Similar Messages

  • Problem inserting a gif into a blob field in a table with sqldev / forms6i

    Problem solved - For those that might be interested, the errors don't make much sense - the problem was with the gif. Seems that these 28 gifs plus the new scans were saved from the scanner with
    GIF - LZW, Transparent color: 255
    Converting them to Black and white allowed them to be loaded.
    If anyone understands why, I'd like to know
    glenn
    I was previously having a problem deleting a row with a blob and it was suggested that I create the table using rowdependencies - which I did as follows.
    CREATE TABLE "MDD"."MDD_FIGURE2"
    (     "FG_FIGURENAME" VARCHAR2(18 BYTE),
         "FG_FIGURE" BLOB,
         CONSTRAINT "FG_FIGURENAME_NN" CHECK ("FG_FIGURENAME" IS NOT NULL) ENABLE
    ) ROWDEPENDENCIES;
    Then I copied my data from my previous table with the following - and everything came across
    INSERT INTO MDD_FIGURE2 (fg_figurename, fg_figure)
    SELECT FIG_FIGNAME, FIG_FIGURE FROM MDD_FIGURE;
    mdd_figure2 was then renamed to mdd_figure
    The table, Mdd_Figure, already contains some 2000+ .gifs that were successfully loaded with Forms 6i (yes, I know it is old, but I am stuck with having to use it). All the .gifs I am loading are from scans and all are less than 64k. However, 28 .gifs would not load. When I insert the .gif into the field and committed the form, the status message tells me a record was written but when I check it, the blob is empty.
    So, when I try to insert one of these problem .gifs in SqlDeveloper, I open the new mdd_figure table, select the blob field, open the edit dialog, set it to figure, select the .gif that I want to load and then save it. The blob field changes from NULL to BLOB, but it is empty. When I try to commit, I get the following error from SqlDev.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAlAAz' AND ORA_ROWSCN = '358136842'
    One error saving changes to table "MDD"."MDD_FIGURE":
    Row 14: ORA-01410: invalid ROWID
    I use rollback to restore the record to it's previous state.
    If I load one of the successfully loaded .gifs into the same field, it loads perfectly as follows.
    UPDATE "MDD"."MDD_FIGURE" SET WHERE ROWID = 'AAAOeWAAEAAABAoAAp' AND ORA_ROWSCN = '358136522'
    Commit Successful
    It appears the 28 gifs have a problem. I've re-scanned them, with the same results. They are just small scanned line map images from our earlier publications. They view properly in several different graphics programs and I can't find anything wrong with them.
    I notice that the ROWID's are different while the ORA_ROWSCN's are the same - but what is the significance of that?
    Any suggestions as to what is happening and what I can do about it?
    Thanks for any help you can give me.
    glenn
    (Database is 10R2 and sqldev is the most recent one)
    Edited by: gconley on Sep 25, 2008 9:51 PM

    solved it myself - problem was with the gif

  • Problem w/ image item using 9i BLOB field and InterMedia ORDImage Object

    Hi,dear all,
    I have a problem with image item in Form 6i. Oracle 9i is used as backend DB, and a table contains image data is created for testing:
    create table image_test(
    id number,
    image blob
    In Form 6i, there is no problem to create a block for inserting/updating the image record into the database. However, it can not be used to retrieve image (blob field), the image item remains empty after 'execute query', while the id field can be retrieved. When the same table is created in Oracle 8.1.7, and the exact same form can be used without any problem both in inserting and retrieval. It seems that the Oracle 9i does not use the same way to store BLOB column. Has anybody ever encountered this problem? How to retrieve image (BLOB) in Form 6i from Oracle 9i?
    I tried to use interMedia ORDImage as the data type in Oracle 9i, that is,
    create table image_test(
    id number,
    image ORDSYS.ORDImage
    Same problem, the form can insert record with image, but when retrieving, nothing displayed. Anybody could help! Thanks in advance!

    hi!
    well working with oracle8i and form6i.
    same problem..but i used (instead of blob or clob as datatype..) Long raw..
    it can be saved as usual..i mean Commit..
    and can be retrieved..using Execute_Query..its working fine..
    well if anybody get any other solution..do inform..
    mail_id:
    [email protected]

  • Creating Packages from BLOB field contents, line wrap problems

    Good afternoon,
    we use an in-house developed database-driven update system to update both our databases and filesystems, the system itself performs really well but there is still one problem I can't fix without some expert help:
    the code of to-be-updated Oracle packages is stored inside of a BLOB field, the BLOB field will contain both the package specification and package body and needs to be split into two parts to first execute the spec and then to execute the package body (I tried to execute both in a single step but this didn't work). This works for packages with less than 32767 characters and also works in some other cases but I found one case where the executed code contains an extra line wrap right in the middle of a word.
    To make it more clear (I hope it's comprehensible), imagine the following database content:
    CREATE OR REPLACE Package
    MyPack
    AS
    [... a lot procedure headers ...]
    END MyPack;
    CREATE OR REPLACE
    Package Body MyPack AS
    [... a lot more procedures ...]
    PROCEDURE myTest (intID OUT integer)
    AS
    BEGIN
      SELECT count (*) into intID FROM MyTa[--this is where the dbms_lob.substr() ends --]ble;
    END;
    END MyPack;My code searches for the second occurrence of the "Create or replace package", splits the code into spec and body, executes the specification and keeps on adding the rest of the code to a VARCHAR2A variable called "storedCode" from the BLOB. Now in the above example, after the specification has been removed from the string, the remaining characters (ending with the "MyTa" string) are added to the varchar2a variable, the next line is fetched from the BLOB via "dbms_lob.substr()" and added as long as dbms_lob.substr() does not return a NULL value (end of BLOB). When the code is executed after all has been fetched, the generated Package Body will contain an extra line wrap right in the middle of the "MyTable" word compiling the package invalid.
    This is the procedure code I use (definitely improvable, I'm better in MSSQL and MySQL dialects ...) to load, parse and execute the BLOB content:
       -- to run package code
      procedure runPackageCode (stepRef integer)
      AS
        numLines integer default 1;
        pos     integer default 1;
        storedCode    LOG_CHANGEDOBJECT.STOREDOBJECT%type;
        objectCursor  integer;
        lSqlOut     integer;
        sqlCommand  dbms_sql.varchar2a;
        emptyCommand dbms_sql.varchar2a;
        pIsError integer := 0;
        pErrorMsg varchar2(200) := '';
        updateRef integer := 0;
        currentUpdate integer := 0;
        schemaReference varchar2(20);
        -- required to do string cutting
        strLine varchar2(32767);
        strLeftFromSlash varchar2(32767);
        strRemaining varchar2(32767);
        intDelimiterPos integer := 0;
      begin
        -- retrieve update ID
        SELECT log_update_ref INTO currentUpdate FROM link_update_with_taskstep WHERE log_taskstep_ref = stepRef;
         begin
            select storedobject, change_area
            into storedCode, schemaReference
            from vw_storedobjects
            where step_id = stepRef;
         exception
          when no_data_found then
            pIsError := 1;
            pErrorMsg := 'Invalid SQL ID ' || stepRef;
            pkg_generic.LogError(updateRef, 'LocalUpdater', stepRef, 'Run package code failed: ' || pErrorMsg);
         end;
          if pIsError = 0 then     
            begin
              -- change schema
              execute immediate 'alter session set current_schema = ' || schemaReference;         
              objectCursor := dbms_sql.open_cursor;   
              loop
                strLine := UTL_RAW.CAST_TO_VARCHAR2(dbms_lob.substr(storedCode, 32767, pos));
                intDelimiterPos := regexp_instr(strLine, '\s*Create\s*or\s*Replace\s*Package', 2, 1, 0, 'i');
                while intDelimiterPos > 0
                loop
                  -- '/' found, execute currently stored statement
                  strLeftFromSlash := substr(strLine, 1, intDelimiterPos-1);
                  strLine := substr(strLine, intDelimiterPos);
                  -- execute the extracted part without any '/' in it
                  sqlCommand(numLines) := regexp_replace(strLeftFromSlash, '(^|\s+)/(\s+|$)', '', 1, 0, 'm');
                  if (sqlCommand(numLines) is not null) then
                    objectCursor := dbms_sql.open_cursor;   
                    dbms_sql.parse(objectCursor, sqlCommand, 1, numLines, true, dbms_sql.native);
                    lSqlOut := dbms_sql.execute(objectCursor);
                    dbms_sql.close_cursor(objectCursor);
                  end if;
                  -- reset sqlCommand
                  sqlCommand := emptyCommand;
                  -- reset line counter and store remaining string
                  numLines := 1;
                  -- check for further '/'s           
                  intDelimiterPos := regexp_instr(strLine, '\s*Create\s*or\s*Replace\s*Package', 2, 1, 0, 'i');
                end loop;
                -- add the remaining strLine to the sqlCommand
                strLine := regexp_replace(strLine, '(^|\s+)/(\s+|$)', '', 1, 0, 'm');
       --> I assume this line breaks the code, lpad()'ing the content to move it to the end of a varchar2a line didn't help
                sqlCommand(numLines) := strLine;
                exit when sqlCommand(numLines) is null;
                pos := pos+32767;
                numLines := numLines+1;
              end loop;
              objectCursor := dbms_sql.open_cursor;   
              dbms_sql.parse(objectCursor, sqlCommand, 1, numLines, true, dbms_sql.native);   
              lSqlOut := dbms_sql.execute(objectCursor);
              dbms_sql.close_cursor(objectCursor);
              commit;
              -- reset schema
              execute immediate 'alter session set current_schema = UPDATE_DB';
              -- set state to installed
              pkg_update.setstepstate(stepRef, 'Installed');
        exception
        when others then
              -- reset schema
              execute immediate 'alter session set current_schema = UPDATE_DB';
              -- set state to installFailed
              pkg_update.setstepstate(stepRef, 'InstallFailed');
              pkg_generic.LogError(updateRef, 'Database', stepRef, 'Run package code failed: ' || sqlerrm);
        end;
        end if;
      END;    Thanks if you kept on reading so far, I would really appreciate any feedback!
    Regards, Sascha

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    Thanks for providing an easy-to-understand problem statement and for using code tags.
    >
    the code of to-be-updated Oracle packages is stored inside of a BLOB field
    >
    This should be stored in a CLOB since it is character data. Why are you using BLOB?
    >
    the BLOB field will contain both the package specification and package body and needs to be split into two parts to first execute the spec and then to execute the package body
    >
    Good, clear problem statement. So why doesn't your code do just what you said it should do: 1) split the code into two parts, 2) execute the spec and 3) execute the body.
    Instead of writing code that does these three relatively simple steps your code tries to combine splitting and executing and mushes/mashes it all together. The result, as you found, is code that is hard to understand, hard to debug, doesn't work and doesn't report on what it is doing.
    Code like this doesn't have a performance issue so the code should implement the simple step-by-step process that you so elegantly stated in your problem description:
    1. split the code into two parts
    2. execute the spec
    3. execute the body
    My advice is to refactor your code to perform the above steps in the proper order and to add proper exception handling and reporting for each step. Then when a step isn't working you will know exactly where and what the problem is.
    Here are my recommendations.
    1. Add two CLOB variables - one will hold the spec, the second will hold the body
    2. Add a comment (you have some good ones in the code now) for every step no matter how trivial it may be
    3. Add exception/error handling to EVERY STEP
    Your code for the first step has a comment but no exception handling. What should happen if you don't get any data? Why aren't you validating the data you get? Dynamic SQL using table-driven data is great, I love it, but you MUST validate that the data you get is what you expect to get.
        -- retrieve update ID
        SELECT log_update_ref INTO currentUpdate FROM link_update_with_taskstep WHERE log_taskstep_ref = stepRef;Recommended
        -- step 1 - retrieve update ID - This is the id that determines BLAH, BLAH, BLAH - add appropriate to tell a new developer what this ID is and what it means.
        BEGIN
            SELECT log_update_ref INTO currentUpdate FROM link_update_with_taskstep WHERE log_taskstep_ref = stepRef;
        EXCEPTION
            WHEN ??? THEN -- what should happen if step 1 fails? Do it here - don't default to an exception handler that is several pages away.
        END;Your code
         begin
            select storedobject, change_area
            into storedCode, schemaReference
            from vw_storedobjects
            where step_id = stepRef;
         exception
          when no_data_found then
            pIsError := 1;
            pErrorMsg := 'Invalid SQL ID ' || stepRef;
            pkg_generic.LogError(updateRef, 'LocalUpdater', stepRef, 'Run package code failed: ' || pErrorMsg);
         end;
    Good - except there is no comment that says what this does - I assume that the query above and this block are the 'retrieve update ID ' step?
    You log an error message and set the error flag to '1'. But since you don't want to continue why aren't you exiting the procedure and returning right here?
          if pIsError = 0 then     
            beginSo now you check the error flag and do several pages of code if there were no errors.
    I don't like that 'inverted' logic.
    If you don't want to continue then STOP right now! Don't make a developer scan through pages and pages of code to find out you really aren't doing anything else if there was an error.
    Either put a RETURN statement in the exception handler above or change your code to
          if pIsError = 1 then     
            RETURN;
          end if;Now the rest of the code doesn' t have to be indented; you will never get there if there is an error. Check for errors after every step and exit right then as appropriate.
              -- change schema
              execute immediate 'alter session set current_schema = ' || schemaReference;         
              objectCursor := dbms_sql.open_cursor;   
              loop
                strLine := UTL_RAW.CAST_TO_VARCHAR2(dbms_lob.substr(storedCode, 32767, pos));
                intDelimiterPos := regexp_instr(strLine, '\s*Create\s*or\s*Replace\s*Package', 2, 1, 0, 'i');
                while intDelimiterPos > 0
                loopThis code mixes all of the steps together into one giant mess. You open a cursor, try to split the BLOB into spec and body and try to parse and execute both all within a double nested loop.
    Even if that works correctly another developer will have a hard time understanding what the code is doing and fixing it if it goes wrong. And it will go wrong if you let me test if for you because I will put garbage into the BLOB for the spec, body or both to make sure it breaks and to see how your code handles it.
    I suggest you rewrite this double nested loop to perform the three steps separately.
    1. split the code into two parts
    a. put the spec into one new CLOB variable and the body into the other.
    b. use DBMS_OUTPUT (or a work table) to output the spec and body so you can see what the code is and make sure the 'split' process worked properly. You probably created that BLOB by manually concatenating the SPEC and BODY to begin with so now create a SPLIT process to split them again and give them back to you. This is such a fundamental component that I suggest creating a new SPLIT_MY_BLOB procedure. This procedure would take a BLOB and return two CLOBS as OUT parameters: one CLOB is the spec and one is the body. Then you can reuse this 'split' procedure in other code or more complex versions of code. Modular programming is the key.
    2. execute the spec - Now have a step that executes the spec and does something appropriate if the step succeeds or if it fails. I mean, do you really want to do execute the body if the spec execution fails? What do you want to do? Should you delete the body and spec? If you don't you might wind up with an INVALID body based on old code and an INVALID spec based on the new code you were trying to use. How will anyone, including you, know that the spec and body in the ALL_SOURCE view is really two different versions of things?
    This suggests that for your use case you may want to consider DROPPING the entire package, spec and body, before trying to recreate them both. At least if the package is totally missing anyone will know that the entire thing needs to be put back. Ahhhh - but to do that you need to know the package name so you can drop it. Than may require adding another step to get the package name from your data-driven table and adding a DROP PACKAGE step.
    3. execute the body - This step executes the body. Hmmmm - we have two nearly identical steps. So why don't you create a new function/procedure that takes a CLOB as input, uses dynamic sql to execute it and returns a result code. That would be useful. Then you could execute ANY sql stored in a CLOB and have a generic function that you can use for other things.
    Right now you are using the VARCHAR2 table version of DBMS_SQL.PARSE but you would change this to use the CLOB version.
    The end result of this refactoring is a main function/procedure that acts as the CONTROL - it decides what to do and what data (BLOB) to do it with. But it doesn't actually do ANY of the work. It just controls what is done.
    And you have a couple of generic, reuseable functions that actually do the work. One knows how to split a CLOB into spec and body. The other knows how to use dynamic SQL to execute a CLOB.
    Now you have a modular architecture that is easy to understand, easy to code and easy to test.

  • Serialization Object and storasge in blob field Oracle 8.1.6

    Hi,
    this is problem with serializing and deserializing when i am storing object serialized in a Blob field Oracle:
    MyObject myObject = new MyObject();
    ByteArrayOutputStream bayos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream (bayos);
    oos.writeObject(myObject);
    oos.flush();
    byte[] buffer = bayos.toByteArray();
    int size = buffer.length;
    oos.close();
    ByteArrayInputStream bayis = new ByteArrayInputStream(buffer,0,size);
    // if the number bytes of serialized myObject > 4kbytes then the insert in Blob field fails down.
    // if the number bytes of serialized myObject < 4kbytes then the insert in Blob field successes.
    // So I only can put in Blob field serialized object with size minus 4k.
    // The code for insert:
    PreparedStatement pstmt = connection.prepareStatement(sqlInsert);
    pstmt.setBinaryStream(1,bayis,size);
    int retCode = pstmt.executeUpdate();
    // The code for read from table Oracle
    rset = stmt.rxecuteQuery(sqlSelect);
    rset.next();
    oracle.sql.BLOB fldBlob = (BLOB)rset.getObject(1);
    InputStream ins = fldBlob.getBinaryStream();
    byte[] buf = new byte[size]
    ByteArrayInputStream bayis = new ByteArrayInputStream(buf,0,size);
    ObjectInputStream ois = new ObjectInputStream(bayis);
    MyObject myObject = (MyObject)ois.readObject();
    Someone knows the reason of the limit of 4Kbyte ?
    Thanks....

    Insert LOBs into Oracle is a 3 step process. You must insert a place holder, and the do a select for update to put the contents into the row. Lets say you have a table called MY_LOB:
    create table MY_LOB (
       MYID NUMERIC(10) NOT NULL,
       MYLOB BLOB DEFAULT EMPTY_BLOB()
    );The 'empty_blob' keyword tells Oracle to put a dummy value in the blob column when a row is initially created. To insert (assuming you have a db connection already):
    conn.setAutoCommit(false);
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    oracle.sql.BLOB myLob = null;
    try
       //Insert the initial row.
       pstmt = conn.prepareStatement("INSERT INTO MY_LOB (MYID) VALUES (?)");
       //Set the PK value
       pstmt.setInt(1,100);
       pstmt.executeUpdate();
       pstmt.close();
       //Lock the row for insertion.  This is needed for large inserts.
       pstmt = conn.prepareStatement("SELECT MYLOB from MY_LOB where MYID = ? FOR UPDATE");
       pstmt.setInt(1,100);
       rs = pstmt.executeQuery();
       if (rs.next())
          myLob = (oracle.sql.BLOB)rs.getBlob(1);
       rs.close();
       pstmt.close();
       //Finally...update the row with the blob data....
       myLob.putBytes(1, buffer);
       pstmt = conn.prepareStatement("UPDATE MY_LOB SET MYLOB = ? WHERE MYID = ?");
       pstmt.setBlob(1, myLob);
       pstmt.setInt(2,100);
       pstmt.executeUpdate();
       pstmt.close();
       conn.commit();
    catch(SQLException sqlE)
        conn.rollback();
    finally
      //make sure and close all statements....
    }Hope this helps, I didn't compile it so it may have some bugs. It should lead in the right direction at least.

  • Streaming blob fields

    i have an object that contains a blob field that i need to be able to
    read/write using streams, rather than creating a byte[] to hold the entire
    thing in memory at once. are there any ways to do this without resorting to
    jdbc? for example, are there any kodo-specific implementation classes that
    i can cast a jdo object to to get extra functionality, or any way to get at
    the underlying input streams kodo using to read blobs?
    any pointers/advice in this area would be greatly appreciated.
    thanks.

    I started what I think is the right approach. What I'm missing is how to
    create
    an extension to OracleBlobMapping so I don't get the:
    java.lang.ClassCastException
    at
    com.solarmetric.kodo.impl.jdbc.ormapping.OracleBlobMapping.update(OracleBlob
    Mapping.java:
    69)
    at
    com.solarmetric.kodo.impl.jdbc.ormapping.LobMapping.insert(LobMapping.java:1
    20)
    at
    com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.insert(ClassMapping.ja
    va:491)
    at
    com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManag
    er.java:413)
    at
    com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManager
    Impl.java:549
    There are no source for the BlobMapping classes I think.
    We are using 2.4.0, but can upgrade to any Kodo including betas...
    Thanks,
    Eivind Skildheim
    Motive Communications, Inc
    "Abe White" <[email protected]> wrote in message
    news:[email protected]...
    We cannot commit to a timeframe on this. I can say, though, that we'll
    be continuing to make it easier to create your own FieldMapping in the
    short term (next 1-3 months; 3.0 release timeframe), so you should be
    able to create your own mapping to handle streaming LOBs. As noted
    before, you have this option at the present time too.begin 666 OracleDictionaryWithBlobs.java
    M<&%C:V%G92!C;VTN;6]T:79E+FID;RYK;V1O.PT*#0HO*BH-"B J($-O<'ER
    M:6=H=" R,# R(&)Y($UO=&EV92!#;VUM=6YI8V%T:6]N<RP@26YC+@T*("H@
    M06QL(')I9VAT<R!R97-E<G9E9"X-"B J#0H@*B!4:&ES('-O9G1W87)E(&ES
    M('1H92!C;VYF:61E;G1I86P@86YD('!R;W!R:65T87)Y(&EN9F]R;6%T:6]N
    M(&]F#0H@*B!-;W1I=F4@0V]M;75N:6-A=&EO;G,L($EN8RX@*")#;VYF:61E
    M;G1I86P@26YF;W)M871I;VXB*2X@(%EO=0T*("H@<VAA;&P@;F]T(&1I<V-L
    M;W-E('-U8V@@0V]N9FED96YT:6%L($EN9F]R;6%T:6]N(&%N9"!S:&%L;"!U
    M<V4@:70-"B J(&]N;'D@:6X@86-C;W)D86YC92!W:71H('1H92!T97)M<R!O
    M9B!T:&4@;&EC96YS92!A9W)E96UE;G0@>6]U#0H@*B!E;G1E<F5D(&EN=&\@
    M=VET:"!-;W1I=F4N#0H@*B\-"@T*:6UP;W)T(&IA=F$N:6\N26YP=713=')E
    M86T[#0II;7!O<G0@:F%V82YS<6PN0FQO8CL-"FEM<&]R="!J879A+G-Q;"Y0
    M<F5P87)E9%-T871E;65N=#L-"FEM<&]R="!J879A+G-Q;"Y297-U;'13970[
    M#0II;7!O<G0@:F%V82YS<6PN4U%,17AC97!T:6]N.PT*#0II;7!O<G0@:F%V
    M87@N:F1O+DI$3T5X8V5P=&EO;CL-"@T*:6UP;W)T(&-O;2YS;VQA<FUE=')I
    M8RYK;V1O+FEM<&PN:F1B8RYO<FUA<'!I;F<N17AP;&EC:71";&]B36%P<&EN
    M9SL-"FEM<&]R="!C;VTN<V]L87)M971R:6,N:V]D;RYI;7!L+FID8F,N;W)M
    M87!P:6YG+D)L;V)-87!P:6YG.PT*:6UP;W)T(&-O;2YS;VQA<FUE=')I8RYK
    M;V1O+FEM<&PN:F1B8RYO<FUA<'!I;F<N17AP;&EC:71/<F%C;&5";&]B36%P
    M<&EN9SL-"FEM<&]R="!C;VTN<V]L87)M971R:6,N:V]D;RYI;7!L+FID8F,N
    M;W)M87!P:6YG+D]R86-L94)L;V)-87!P:6YG.PT*:6UP;W)T(&-O;2YS;VQA
    M<FUE=')I8RYK;V1O+FEM<&PN:F1B8RYS8VAE;6$N9&EC="Y/<F%C;&5$:6-T
    M:6]N87)Y.PT*#0II;7!O<G0@;W)G+F%P86-H92YL;V<T:BY,;V=G97([#0H-
    M"G!U8FQI8R!C;&%S<R!/<F%C;&5$:6-T:6]N87)Y5VET:$)L;V)S#0H@(" @
    M97AT96YD<R!/<F%C;&5$:6-T:6]N87)Y#0I[#0H@(" @<')I=F%T92!#;&%S
    M<UM=(%]F:65L9$-L87-S97,@/2!N=6QL.PT*#0H@(" @<'5B;&EC($]R86-L
    M941I8W1I;VYA<GE7:71H0FQO8G,H*0T*(" @('L-"B @(" @(" @<W5P97(H
    M*3L-"B @("!]#0H@(" @#0H@(" @+RHJ#0H@(" @("H@0V]N=F5R="!V86P@
    M=&\@<W%L('9A;'5E#0H@(" @("HO#0H@(" @<'5B;&EC($]B:F5C="!B;&]B
    M5&]344P@*$]B:F5C="!V86PI#0H@(" @>PT*(" @(" @("!O<F<N87!A8VAE
    M+FQO9S1J+DQO9V=E<BYG971,;V=G97(H=&AI<RYG971#;&%S<R@I*2YI;F9O
    M*"(J*BH@8FQO8E1O4U%,(#HB("L@=F%L*3L-"B @(" @(" @:68@*"AN=6QL
    M("$]('9A;"D-"B @(" @(" @(" @("8F("AV86P@(3T@3W)A8VQE0FQO8DUA
    M<'!I;F<N14U05%E?0DQ/0BDI#0H@(" @(" @('L-"B @(" @(" @(" @("\O
    M('-T<F5A;7,N#0H@(" @(" @(" @("!R971U<FX@=F%L.R -"B @(" @(" @
    M?0T*(" @(" @("!E;'-E#0H@(" @(" @('L-"B @(" @(" @(" @(')E='5R
    M;B!S=7!E<BYB;&]B5&]344PH=F%L*3L-"B @(" @(" @?0T*(" @('T-"@T*
    M(" @('!U8FQI8R!/8FIE8W0@8FQO8D9R;VU344P@*%)E<W5L=%-E="!R<RP@
    M:6YT(&-O;'5M;BD-"B @(" @(" @=&AR;W=S(%-13$5X8V5P=&EO;@T*(" @
    M('L-"B @(" @(" @3&]G9V5R+F=E=$QO9V=E<BAT:&ES+F=E=$-L87-S*"DI
    M+FEN9F\H(BHJ*B!B;&]B1G)O;5-13" Z(B K(&-O;'5M;BD[#0H@(" @(" @
    M($)L;V(@8FQO8B ]("A";&]B*2!R<RYG971";&]B("AC;VQU;6XI.PT*(" @
    M(" @("!I9B H8FQO8B ]/2!N=6QL*0T*(" @(" @(" @(" @<F5T=7)N(&YU
    M;&P[#0H-"B @(" @(" @=')Y#0H@(" @(" @('L-"B @(" @(" @(" @("\O
    M(')E='5R;B!A<R!S=')E86T-"B @(" @(" @(" @(')E='5R;B!B;&]B+F=E
    M=$)I;F%R>5-T<F5A;2 H*3L-"B @(" @(" @?0T*(" @(" @("!C871C:" H
    M17AC97!T:6]N(&4I#0H@(" @(" @('L-"B @(" @(" @(" @('1H<F]W(&YE
    M=R!*1$]%>&-E<'1I;VX@*&4N9V5T365S<V%G92 H*2P@92D[#0H@(" @(" @
    M('T-"B @("!]#0H-"B @(" O+R!/<F%C;&4@:7,@<W1R86YG92X@5&AI<R!C
    M;V1E(')E<75I<F5S($I$0D,R+@T*(" @('!U8FQI8R!V;VED(&)L;V)4;U!R
    M97!A<F5D4&%R86UE=&5R("A0<F5P87)E9%-T871E;65N="!S="P@:6YT(&DL
    M( T*(" @(" @("!/8FIE8W0@;RD-"B @(" @(" @=&AR;W=S(%-13$5X8V5P
    M=&EO;@T*(" @('L-"B @(" @(" @3&]G9V5R+F=E=$QO9V=E<BAT:&ES+F=E
    M=$-L87-S*"DI+FEN9F\H(BHJ*B!B;&]B5&]0<F5P87)E9%!A<F%M971E<B Z
    M(B K(&DI.PT*(" @(" @("!I9B H;R ]/2!N=6QL*0T*(" @(" @("![#0H@
    M(" @(" @(" @(" O+R%S="YS971";&]B("AI+"!O<F%C;&4N<W%L+D),3T(N
    M96UP='E?;&]B("@I*3L-"B @(" @(" @(" @('-U<&5R+F)L;V)4;U!R97!A
    M<F5D4&%R86UE=&5R*'-T+"!I+"!O*3L-"B @(" @(" @?0T*(" @(" @("!E
    M;'-E#0H@(" @(" @('L-"B @(" @(" @(" @($]B:F5C="!B;&(@/2!B;&]B
    M5&]344P@*&\I.PT*(" @(" @(" @(" @:68@*&)L8BYE<75A;',@*$5-4%19
    M7T),3T)?4U1224Y'*2D-"B @(" @(" @(" @('L-"B @(" @(" @(" @(" @
    M("!S="YS971";&]B("AI+"!O<F%C;&4N<W%L+D),3T(N96UP='E?;&]B("@I
    M*3L-"B @(" @(" @(" @('T-"B @(" @(" @(" @(&5L<V4-"B @(" @(" @
    M(" @('L-"B @(" @(" @(" @(" @(" O+R!N;W0@<W5R92!W:&5N($D@=VEL
    M;"!G970@:&5R92XN+BXN#0H@(" @(" @(" @(" @(" @=&AR;W<@;F5W(%)U
    M;G1I;65%>&-E<'1I;VXH(E=H>2!D:60@22!G970@:&5R93\B*3L-"B\O(" @
    M(" @(" @(" @(" @("\O(6)Y=&5;72!B;&]B0GET97,@/2 H8GET95M=*2!S
    M=7!E<BYB;&]B5&]344P@*&\I.PT*+R\@(" @(" @(" @(" @(" @8GET95M=
    M(&)L;V)">71E<R ]('LP+#$L,GT[#0HO+R @(" @(" @(" @(" @("!O<F%C
    M;&4N<W%L+D),3T(@9&)";&]B(#T@;F5W(&]R86-L92YS<6PN0DQ/0B H#0HO
    M+R @(" @(" @(" @(" @(" @(" @*&]R86-L92YJ9&)C+D]R86-L94-O;FYE
    M8W1I;VXI<W0N9V5T0V]N;F5C=&EO;B H*2P@#0HO+R @(" @(" @(" @(" @
    M(" @(" @8FQO8D)Y=&5S*3L-"B\O(" @(" @(" @(" @(" @('-T+G-E=$)L
    M;V(@*&DL("A";&]B*2!D8D)L;V(N=&]*9&)C("@I*3L-"B @(" @(" @(" @
    M('T-"B @(" @(" @?0T*(" @('T-"@T*(" @( T*(" @('!U8FQI8R!#;&%S
    M<UM=(&=E=$9I96QD36%P<&EN9T-A;F1I9&%T94-L87-S97,@*"D-"B @("![
    M#0H@(" @(" @(&EF("A?9FEE;&1#;&%S<V5S(#T](&YU;&PI#0H@(" @(" @
    M('L-"B @(" @(" @(" @($-L87-S6UT@<W5P97)#;&%S<V5S(#T@<W5P97(N
    M9V5T1FEE;&1-87!P:6YG0V%N9&ED871E0VQA<W-E<R H*3L-"B @(" @(" @
    M(" @(%]F:65L9$-L87-S97,@/2!N97<@0VQA<W-;<W5P97)#;&%S<V5S+FQE
    M;F=T:%T[#0H@(" @(" @(" @("!3=')I;F<@8VQA<W-.86UE.PT*(" @(" @
    M(" @(" @9F]R("AI;G0@:2 ](# [(&D@/"!?9FEE;&1#;&%S<V5S+FQE;F=T
    M:#L@:2LK*0T*(" @(" @(" @(" @>PT*(" @(" @(" @(" @(" @(&-L87-S
    M3F%M92 ]('-U<&5R0VQA<W-E<UMI72YG971.86UE("@I.PT*(" @(" @(" @
    M(" @(" @(&EF("AC;&%S<TYA;64N97%U86QS("A";&]B36%P<&EN9RYC;&%S
    M<RYG971.86UE("@I*2D-"B @(" @(" @(" @(" @("![#0H@(" @(" @(" @
    M(" @(" @(" @("\O(2$A($D@;F5E9"!A(&-U<W1O;2!C;&%S<R!H97)E#0H@
    M(" @(" @(" @(" @(" @(" @(%]F:65L9$-L87-S97-;:5T@/2!/<F%C;&5"
    M;&]B36%P<&EN9RYC;&%S<SL-"B @(" @(" @(" @(" @("!]#0H@(" @(" @
    M(" @(" @(" @96QS92!I9B H8VQA<W-.86UE+F5Q=6%L<R -"B @(" @(" @
    M(" @(" @(" @(" @(" @(" H17AP;&EC:71";&]B36%P<&EN9RYC;&%S<RYG
    M971.86UE("@I*2D-"B @(" @(" @(" @(" @("![#0H@(" @(" @(" @(" @
    M(" @(" @("\O(2$A($D@;F5E9"!A(&-U<W1O;2!C;&%S<R!H97)E#0H@(" @
    M(" @(" @(" @(" @(" @(%]F:65L9$-L87-S97-;:5T@/2!%>'!L:6-I=$]R
    M86-L94)L;V)-87!P:6YG+F-L87-S.PT*(" @(" @(" @(" @(" @('T-"B @
    M(" @(" @(" @(" @("!E;'-E#0H@(" @(" @(" @(" @(" @>PT*(" @(" @
    M(" @(" @(" @(" @("!?9FEE;&1#;&%S<V5S6VE=(#T@<W5P97)#;&%S<V5S
    M6VE=.PT*(" @(" @(" @(" @(" @('T-"B @(" @(" @(" @('T-"B @(" @
    M(" @?0T*(" @(" @("!R971U<FX@7V9I96QD0VQA<W-E<SL-"B @("!]#0H@
    ((" @#0I]#0H`
    `
    end

  • Error while trying to store PDF in Oracle's BLOB field

    Hi folks!
    I'm having problems while trying to store PDF file in a BLOB field of an Oracle table
    This is the message code:
    Exception in thread "main" java.sql.SQLException: Data size bigger than max size for this type: 169894
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:95)
    at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2414)
    at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1134)
    at oracle.jdbc.driver.OraclePreparedStatement.setBytes(OraclePreparedStatement.java:2170)
    at vgoactualizacion.Main.main(Main.java:84)     
    This is the piece of code i'm using:
    Assuming conn = conection to Oracle 10g Database ( it's working )
    String miProcedimientoAlmacenado = "{ call package_name.update_client(?,?, ?) }";
    CallableStatement miComando = conn.prepareCall(miProcedimientoAlmacenado);
    miComando.setString(1,miClienteID ); //first parameter : IN
                   //second parameter : IN
    File miPDF = new File(pathPDF + "//" + miClienteID + ".pdf");
    byte[] bodyIn = readFully(miPDF); //readFully procedure is shown below
    miComando.setBytes(2, bodyIn); //THIS IS THE LINE WHERE THE ERROR IS PRODUCED
              //3rd parameter: OUT
    miComando.registerOutParameter(3, java.sql.Types.VARCHAR);
    miComando.execute();
    private static byte[] readFully(File miPDF) throws FileNotFoundException, IOException {
    FileInputStream fis = new FileInputStream(miPDF);
    byte[] tmp = new byte[1024];
    byte[] data = null;
    int sz, len = 0;
    while ((sz = fis.read(tmp)) != -1) {
    if (data == null) {
    len = sz;
    data = tmp;
    } else {
    byte[] narr;
    int nlen;
    nlen = len + sz;
    narr = new byte[nlen];
    System.arraycopy(data, 0, narr, 0, len);
    System.arraycopy(tmp, 0, narr, len, sz);
    data = narr;
    len = nlen;
    if (len != data.length) {
    byte[] narr = new byte[len];
    System.arraycopy(data, 0, narr, 0, len);
    data = narr;
    return data;
    }//fin readFully
    This approach indicates that the PDF file is converted into an array of bytes, then is stored as binary in the BLOB field.
    Thanx in advance, and looking forward for your comments.

    You will probably need to use the setBinaryStream() method instead of setBytes().

  • 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

  • How to Get a BLOB Field from JDBC Coding

    Hi,
    I have written the JDBC Code to get the field values from the Table.
    There is a BLOB field in that table.
    How to get the BLOB ? What is the return type we should use.
    If it is Varchar then we can use rs.getString().
    If it is BLOB then what is the return type?
    Thanks in Advance

    Blob.
    You know, people like you really give me the urge to print out several hundred pages of Java API and smack them on their heads.

  • Retrieve XMLP documents directly from BLOB fields in E1; Tools Release 8.97

    Hi,
    I want to be able to retrieve XML Publisher reports (PDF, RTF, HTML) directly from the database BLOB fields in EnterpriseOne. Instead of making users manually save each report to get a soft-copy of the report, I wanted to be able to retrieve the reports from a BLOB field, create a new external file for it, and open the file with the related editor (MS Word, Adobe, IE, etc.).
    We are on Oracle 10g, and I was able to get a file populated with some BLOB data for a particular RTF file. However, when I try to open the file in MS Word, all I get is junk.
    Does anyone know if JDE stores these documents differently into BLOB fields than standard?
    Here is the code I used using PL/SQL...
    DECLARE
    xmlstr BLOB;
    warn VARCHAR2(400);
    v_file Utl_File.file_type;
    line_buf RAW(32767);
    maxbufsize BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset BINARY_INTEGER;
    dir varchar2(50) := 'XMLP_DIR';
    filename varchar2(50) := 'JPARK_TEST.rtf';
    bsize NUMBER;
    BEGIN
    v_file := utl_file.fopen(dir,filename,'wb',maxbufsize);
    SELECT xorpdxpblb INTO xmlstr FROM sy812.F95631 WHERE xorpdorgud = '2115630440008e-SMNQTWZCFI-YEKRWCIOUA';
    --SELECT xdrpdubblb INTO xmlstr FROM sy812.F95630 WHERE xdrpduogud = '21080156900001-SMNQTWZCFI-ORORNYFSYJ';
    bsize := dbms_lob.getLength(xmlstr);
    dbms_output.put_line(bsize);
    amount := maxbufsize;
    offset := 1;
    WHILE (offset<bsize) LOOP
    DBMS_LOB.read(xmlstr,amount,offset,line_buf);
    utl_file.put_raw(v_file,line_buf, TRUE);
    offset := offset+amount;
    --utl_file.fflush(v_file);
    --Dbms_Output.put_line(offset);
    END LOOP;
    utl_file.fclose(v_file);
    EXCEPTION
    WHEN OTHERS THEN
    UTL_FILE.FCLOSE_ALL;
    DBMS_OUTPUT.PUT_LINE('WHEN OTHERS');
    dbms_output.put_line(substr(sqlerrm,1,254));
    END;

    the database and blob fields are identical. In the 11i (eBusiness suite) we would store this information in fnd_lobs.
    Ike Wiggins
    http://bipublisher.blogspot.com

  • How to store file content in BLOB field MySql database using java

    Hi!
    i want to store the file content in a BLOB field in MySql database using java.
    Please help me out..........
    thanx in advance...
    bye

    i stored images in db, and retrieved them. like that cant i store pdf file in db, and retrieve it back using oracle db?
    Plz help me out how to put a file in db. i need complete code. thanks in advance.

  • Oracle error ORA-01461when trying to insert into an ORACLE BLOB field

    I am getting Oracle error ‘ORA-01461: can bind a LONG value only  for insert into a LONG column' when trying to insert into an ORACLE BLOB field. The error occurs when trying to insert a large BLOB (JPG), but does not occur when inserting a small (<1K) picture BLOB.(JPG). Any ideas?
    BTW, when using a SQL Server datasource using the same code.... everything works with no problems.
    ORACLE version is 11.2.0.1
    The ORACLE datasource is JDBC using Oracle's JDBC driver ojdbc6.jar v11.2.0.1 (I also have tried ojdbc5.jar v11.2.0.1; ojdbc5.jar v11.2.0.4; and ojdbc6.jar v11.2.0.4 with the same error result.)
    Here is my code:
    <cfset file_mime = Lcase(Right(postedXMLRoot.objname.XmlText, 3))>
    <cfif file_mime EQ 'jpg'><cfset file_mime = 'jpeg'></cfif>
    <cfset file_mime = 'data:image/' & file_mime & ';base64,'>
    <cfset image64 = ImageReadBase64("#file_mime##postedXMLRoot.objbase64.XmlText#")>
    <cfset ramfile = "ram://" & postedXMLRoot.objname.XmlText>
    <cfimage action="write" source="#image64#" destination="#ramfile#" overwrite="true">
    <cffile action="readbinary" file="#ramfile#" variable="image_bin">
    <cffile action="delete" file="#ramfile#">
    <cfquery name="InsertImage" datasource="#datasource#">
    INSERT INTO test_images
    image_blob
    SELECT
    <cfqueryparam value="#image_bin#" cfsqltype="CF_SQL_BLOB">
    FROM          dual
    </cfquery>

    Can't you use "alter index <shema.spatial_index_name> rebuild ONLINE" ? Thanks. I could switch to "rebuild ONLINE" and see if that helps. Are there any potential adverse effects going forward, e.g. significantly longer rebuild than not using the ONLINE keyword, etc? Also wondering if spatial index operations (index type = DOMAIN) obey all the typical things you'd expect with "regular" indexes, e.g. B-TREE, etc.

  • Migrating a table with BLOB field from SQL-Server to Oracle.

    Hi All,
    I'm trying to create a Class to migrate data from SQL-Server to Oracle, this table has a BLOB field.
    The Code:
    package br.com.infox;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class Migrador {
         public static void main(String[] args){
              try {
                   // Conex�o com o SQL Server
                   Class.forName("net.sourceforge.jtds.jdbc.Driver");
                   Connection conSQL = DriverManager.getConnection ("jdbc:jtds:sqlserver://10.10.2.9/protocolo","prot","suinf2002");
                   // Conex�o com o Oracle
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   Connection conORA = DriverManager.getConnection ("jdbc:oracle:thin:@10.10.2.2:1521:des","protocolo","protocolo");
                   Statement stSQL = conSQL.createStatement();
                   String querySQL = "SELECT * FROM DOC_INCORPORADO";
                   ResultSet rsSQL = stSQL.executeQuery(querySQL);
                   String queryORA = "INSERT INTO PROT_VITALICIAMENTO (NU_PROCESSO, ANO_PROCESSO, CD_USUARIO, DT_ENVIO," +
                             "DE_COMPLEMENTO, NM_ARQUIVO, ARQUIVO, NU_SEQ, CD_TIPO_ARQUIVO, MES, ANO) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
                   PreparedStatement psORA = conORA.prepareStatement(queryORA);
                   while (rsSQL.next()){
                        System.out.println("Linha: " + rsSQL.getRow());
                        psORA.setInt(1, rsSQL.getInt("nu_processo"));
                        psORA.setInt(2, rsSQL.getInt("ano_processo"));
                        psORA.setInt(3, rsSQL.getInt("cd_usuario"));
                        psORA.setDate(4, rsSQL.getDate("dt_incorporacao"));
                        psORA.setString(5, rsSQL.getString("complemento"));
                        psORA.setString(6, rsSQL.getString("nm_arquivo"));
                        psORA.setBinaryStream(7, rsSQL.getBinaryStream("arquivo"), (int)rsSQL.getBlob("arquivo").length());
                        psORA.setInt(8, rsSQL.getInt("num_seq"));
                        psORA.setInt(9, rsSQL.getInt("cd_tipo_arquivo"));
                        psORA.setInt(10, rsSQL.getInt("mes"));
                        psORA.setInt(11, rsSQL.getInt("ano"));
                        psORA.executeUpdate();
                   stSQL.close();
                   psORA.close();
                   conORA.close();
                   conSQL.close();
              } catch (Exception e){
                   e.printStackTrace();
    The ERROR:
    java.sql.SQLException: Exce��o de E/S: Connection reset
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
         at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3668)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1119)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2191)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2064)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2989)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:658)
         at br.com.infox.Migrador.main(Migrador.java:41)
    What's the problem of these Class?
    Thank's.

    Depending on the version of the database you have, you could use transportable tablespaces.
    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96524/c04space.htm#9370

  • Error displaying a jpg file loaded into a table with blob field

    This may not be the correct forum for this question, but if it isn't could someone direct me to the correct one.
    I have created a table with a blob field in which I have loaded a jpg image. This appeared to work correctly, but when I try to display the image in internet explorer it comes back and tells me that it doesn't recognize the file type. Enclosed is the table create, load, and display pl/sql code. Can anyone tell me what I am doing wrong. Thanks. For the mime/header I used owa_util.mime_header('images/jpg') because my image is a jpg file.
    The database is 10g
    -- Create table
    create table PHOTOS
    IMAGEID NUMBER(10),
    IMAGE BLOB,
    IMAGE_NAME VARCHAR2(50)
    load image
    CREATE OR REPLACE PROCEDURE load_file ( p_id number, p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('SNAPUNCH', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO photos (imageid, image_name, image)
    VALUES (p_id , p_photo_name, EMPTY_BLOB())
    RETURNING image INTO dst_file;
    -- lock record
    SELECT image
    INTO dst_file
    FROM photos
    WHERE imageid = p_id AND image_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE photos
    SET image = dst_file
    WHERE imageid = p_id
    AND image_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;
    display image
    PROCEDURE display_image(p_id NUMBER) IS
    Photo BLOB;
    v_amt NUMBER DEFAULT 4096;
    v_off NUMBER DEFAULT 1;
    v_raw RAW(4096);
    BEGIN
    -- Get the blob image
    SELECT image
    INTO Photo
    FROM PHOTOS
    WHERE IMAGEID = p_id;
    owa_util.mime_header('images/jpg');
    BEGIN
    LOOP
    -- Read the BLOB
    dbms_lob.READ(Photo, v_amt, v_off, v_raw);
    -- Display image
    htp.prn(utl_raw.cast_to_varchar2(v_raw));
    v_off := v_off + v_amt;
    v_amt := 4096;
    END LOOP;
    dbms_lob.CLOSE(Photo);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    END;
    The url I enter is: http://webdev:7777/tisinfo/tis.tiss0011.Display_Image?p_id=1

    Just a little more information. When I enter owa_util.mime_header('image/jpeg') I can't display the file. It just shows up with a red x for the file.
    When I enter owa_util.mime_header('image/jpg') it displays the file, but in the format
    ¿¿¿¿JFIF¿¿-Intel(R) JPEG Library, version [2.0.16.48]¿¿C
    This is the way I would expect it to look if I opened it with Notepad, or an application that doesn't recognize jpg files. Can anyone tell me what I am doing wrong?? Thanks.

  • Downloading a file from Database [Blob field]

    I am trying to write an application which can upload and download files [Excel, Word etc.] to/from an Oracle 9i database Blob field. I am using Java/JSP for the same.
    The upload part works just fine. However, when I try to download the file that I uploaded, I get an error.
    A dialog box comes up asking me to Open/Save the file. However, when I try to save it, it says
    �Internet Explorer cannot download �..tion=download&planId= testplan from localhost
    Internet Explorer was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.�
    I am using IE 6.0. I tested the same with Firefox browser and was able to download the file.
    Can anyone help?
    Code:
    Following is the code I am using for the same.
    /* Code to retrieve from Blob field */
    String sqlString = "SELECT PLAN_DOCUMENT_NAME,PLAN_DOCUMENT FROM BRS_PLAN_DESCRIPTION WHERE PLAN_ID = ?";
    ps = con.prepareStatement(sqlString);
    ps.setString (1,planId);
    rs = ps.executeQuery();
    while (rs.next()) {
         fileBytes = rs.getBytes("PLAN_DOCUMENT");
         fileName = rs.getString("PLAN_DOCUMENT_NAME");
    brsPlanDocument.setPlanId(planId);
    brsPlanDocument.setFileName(fileName);
    brsPlanDocument.setFileBytes(fileBytes);
    /* Code for download */
    String fileName = brsPlanDocument.getFileName();
    String fileType = fileName.substring(fileName.indexOf(".")+1,fileName.length());
    if (fileType.trim().equalsIgnoreCase("txt"))
         response.setContentType( "text/plain" );
    else if (fileType.trim().equalsIgnoreCase("doc"))
         response.setContentType( "application/msword" );
    else if (fileType.trim().equalsIgnoreCase("xls"))
         response.setContentType( "application/vnd.ms-excel" );
    else if (fileType.trim().equalsIgnoreCase("pdf"))
         response.setContentType( "application/pdf" );
    else if (fileType.trim().equalsIgnoreCase("ppt"))
         response.setContentType( "application/ppt" );
    else
         response.setContentType( "application/octet-stream" );
    response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
    response.setHeader("cache-control", "no-cache");
    byte[] fileBytes=brsPlanDocument.getFileBytes();
    ServletOutputStream outs = response.getOutputStream();
    outs.write(fileBytes);
    outs.flush();
    outs.close();

    Hi,
    is this problem solved for you, I am also writing the java code to store different files in blob fields in database(db2udb) and allow users to open them through jsp pages. Upload seems to be working fine.....My big problem is only excel files are opened properly in both IE and Firefox. Word files, image files are not getting opened. Any suggestion as what I could be doing wrong....my jsp is kind of similar to the above one...
    thanks in advace, please guide me
    long pmsId = new Long(request.getParameter("pmsId")).longValue();
    String fileName = request.getParameter("fileName");
    int fileSeq = new Integer(request.getParameter("fileSeq")).intValue();
    if(fileName.endsWith("txt")) {
    response.setContentType("text/plain");
    log.debug(" this is a text file");
    } else if(fileName.endsWith("xls")) {
    response.setContentType("application/vnd.ms-excel");
    log.debug(" this is a excel file");
    } else if(fileName.endsWith("gif")) {
    response.setContentType("image/gif");
    log.debug(" this is a image file");
    } else if(fileName.endsWith("doc")) {
    response.setContentType("application/msword");
    log.debug(" this is a doc file");
    } else if(fileName.endsWith("pdf")) {
    response.setContentType("application/pdf");
    log.debug(" this is a pdf file");
    } else if(fileName.endsWith("ppt")) {
    response.setContentType("application/ppt");
    log.debug(" this is a ppt file");
    } else {
    response.setContentType("application/everythingelse");     
    log.debug(" this is a unknown ile");
    response.setHeader("Content-Disposition", "attachment;filename="+fileName);
    OutputStream out1 = response.getOutputStream();
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    db2Conn = DriverManager.getConnection("jdbc:db2:TESTDB","db2admin","db2fv1000");
    //log.debug("connection obtained");
    pstmt = db2Conn.prepareStatement(" SELECT * FROM UPLOADDOCS WHERE PMSID = ? AND DOCSEQ = ? ");
    //log.debug("statemenmt prepared");
    pstmt.setLong(1, pmsId);
    pstmt.setInt(2, fileSeq);
    rs = pstmt.executeQuery();
    int count = 0;
    if(rs.next()){
    InputStream is = rs.getBinaryStream("DOCUMENT"); //"is" is
    //now the binary data
    //of the file
    byte[] buf = new byte[4096];
    int len;
    while ((len = is.read(buf)) > 0)
         out1.write(buf, 0, len);
    out1.close();
    out1.flush();

Maybe you are looking for

  • How to save photos from an external memory

    How do I save photos to my new MacBook Air from an external memory (StoreEdge)? And how do I know where the photos that I can view in Iphoto are stored? I thought I had copied a whole Iphoto library from StoreEdge to my MacBook, but when I try to rem

  • Can't send email when not on my home wifi

    I use roadrunner as my email.  I also have my own domain that I forward my email to my roadrunner email address.  I have configured my email using the settings at http://help.rr.com/hmsfaqs/e_rrmail_emailSettings_iphone.aspx.  I have double check it.

  • Error while executing query in query designer and RSRT.

    Hello All, At none of the places (BI--> RSRT  or via query designer GUI) my query is executing properly . At RSRT the error message --- At Bex Query designer the error msg-- Checked the data at the sales-infocube level , the data is absolutely ok. Re

  • IMessage iOS 8 "Leave group Conversation" not working

    I've been trying to use the "Leave group Conversation" feature of the "Details" page of iMessage in iOS 8, and I cannot get it to work. I've reset my network settings, logged in and out of iCloud, and restarted the phone. No luck. Is anyone else havi

  • Can't run iTunes "Feature is on network resource that is unavail"

    I upgraded to iTunes 7.1. whatever the latest version is just 2 days ago. Now when I try to launch it gave me an error. I tried to uninstall and reinstall, but when I try to reinstall I get "The Feture you are trying to use is on a network resource t