Update blob column

dear all
I am new to oracle database...
and i create one BLOB column to insert the images..
i can insert and retrieve the image data...
but i cant update this column...
can any one guide me to do this.
i tried to empty the column and update but still fails..
update tablename set columnname=empty_blob()
i tried the above and its clear the data ...but again i cant update this ...
i am using oracle 10g express edition.
any suggestion
thank you

i tried to empty the column and update but still fails..How does it fail? Please describe the behaviour in more detail, including any error messages and related information.
Cheers, APC
blog: http://radiofreetooting.blogspot.com

Similar Messages

  • Error when updating blob column

    Hello,
    im using the SQL-Developer and i have problems with updating blob columns.
    I'm getting the following error:
    UPDATE "MED400_INSTALL"."AMEDN_INSURANCE_TEMPL" SET WHERE ROWID = 'AAM6j5ABGAAAADpAAJ' AND ORA_ROWSCN = '26019698898'
    One error saving changes to table "MED400_INSTALL"."AMEDN_INSURANCE_TEMPL":
    Row 15: ORA-01410: Ungültige ROWID
    I'm updating different tables and different rows.
    This error is not shown in all cases. I can update some rows but not all off them.
    Is this a bug?
    TIA

    I made some further investigations and have some more results.
    - the problem does not occur all the time
    - the problem seems to occur in the following situation
    - User A: updates the blob-field using the sql developer menu and commits (-> success)
    - User B: updates the blob-field using the sql developer menu and tries to commit (-> error)
    - the error stays until User B does a rollback, after the rollback user B can update the blob-field! and user A gets the error.
    Here are some extracts of sql developer log. It shows that the same row can be updated in somes cases, in others cases you get an error. After a rollback the field can be updated successfully The rowid ist the same. ora_rowscn is different:
    UPDATE "AZUBI2"."AMEDN_INSURANCE_TEMPL" SET WHERE ROWID = 'AAc6TTACEAAAAHQAAC' AND ORA_ROWSCN = '26087686991'
    One error saving changes to table "AZUBI2"."AMEDN_INSURANCE_TEMPL":
    Row 1: ORA-01410: Ungültige ROWID
    Rollback Successful
    UPDATE "AZUBI2"."AMEDN_INSURANCE_TEMPL" SET WHERE ROWID = 'AAc6TTACEAAAAHQAAC' AND ORA_ROWSCN = '26087687075'
    Commit Successful
    I could offer a dump where you can possibly reproduce this issue. Where can I send or upload it.
    Best regards,
    zebadmin

  • Help! Problem Updating Blob Columns

    Good day
    Please i have problems updating Blob columns storing images and doc files. can someone put me through the way out hassle free
    Thank You
    God Bless U all
    Femi

    I keep geting this error
    java.sql.SQLException: ORA-01729: database link name expected
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
    when ever i try to update The Blob colum with a Blob object retrieved by resultset.getBlob from another Blob column of a different table.
    Blob b = rset.getBlob(1);
    String x = (String)jComboBox2.getSelectedItem();     
         ps=c.prepareStatement("UPDATE PROPERTIES SET "+x+" = "+b+" WHERE NAME = ?");
         ps.setString(1, (String)jComboBox1.getSelectedItem());
         System.out.println("success");
         ps.executeUpdate();

  • Problem at update blob columns.

    Hi,i have a table like this.
    create table customer
    (id number,
    photo blob,
    sign blob,
    pass_view blob);
    I have a form based to this table (at 9i) which has 3 image item.
    By using webutil i read image files to this items and after commit i stored them to database.There is no problem up to this time,inserting data to database seems correct.
    Now i want to update an imge from database and I open form again and execute query.All 3 images was seen.I changed 3rd pass_view image again by reading another image file from file system.After commit and execute_query again i understood that photo column is now having new pass_view image and pass_view column is null.
    In trying different loading to different images,i have problems again.
    Only if i read 3 images from 3 files to image items again,i have no problem in updating.
    Is there a problem in having 3 blob columns in a table?

    I have the problem even with 2 images (2 BLOB fields in table).
    Forms application updates the first image if you replace only the second image. If you replace both images everything is correct.
    Honestly speaking I have this problem with 9.0.2 version and probably in couple weeks I'll test it on 9.0.4.
    Thanks
    Vitaliy

  • Problem Updating BLOB Data in DB

    Hi, There,
    I have a problem when updating BLOB data in database table. I am
    using Oracle 8.1.6, JDK1.3.0., oracle thin driver.
    I have a Handle object handle (javax.ejb.Handle), and I need to
    save this object in DB. The table has 2 columns: column 1
    is "PK" Varchar2(30) Primary Key, column 2 is "HANDLE" BLOB.
    According to the documentation I found from Oracle, I first
    initialize the blob column, and then get the BLOB locator.
    However when I try to update the BLOB data by invoking
    executeUpdate() method on OraclePreparedStatement ops, I always
    get the returned int rowCount=0, which indicates that no rows
    have been updated. (This is verified by trying to retrieve the
    BLOB column value which results in SQLException: Exhausted
    Resultset.)
    Any suggestions what was wrong with the code? Thank you a lot in
    advance!
    Tom
    Part of the code is listed below:
    // If jSessionID is not found, create it
    HttpSession session = request.getSession(true);
    String jSessionID = session.getId();
    //get the Hanlde object for MemberInfo bean
    javax.ejb.Handle handle = memberValidate.validateMember(
    memberID, "" );
    oracle.sql.BLOB oracleBlob = null;
    /* Get DB connection */
    try
    Connection conn = getDBConnection(); // with oracle thin driver
    conn.setAutoCommit(false);
    catch (NamingException ne)
    System.out.println( "Failed to getDBConnection due to Naming
    Exception" + ne.toString() );
    return;
    catch (SQLException sqle)
    System.out.println( "Failed to getDBConnection due to SQL
    Exception"+ sqle.toString() );
    return;
    try
    pstmt=conn.prepareStatement("CREATE TABLE TOM1 (PK VARCHAR(30)
    PRIMARY KEY, HANDLE BLOB NOT NULL)");
    pstmt.execute();
    pstmt=conn.prepareStatement("INSERT INTO TOM1 VALUES('ROW1',
    EMPTY_BLOB())");
    pstmt.executeUpdate();
    pstmt=conn.prepareStatement("SELECT HANDLE FROM TOM1 WHERE
    PK=? FOR UPDATE");
    pstmt.setString(1, "ROW1");
    ResultSet rset = pstmt.executeQuery();
    if ( rset.next() )
    // Get the LOB locator from the ResultSet
    oracleBlob = ((OracleResultSet)rset).getBLOB("HANDLE");
    OraclePreparedStatement ops = null;
    ops = ( OraclePreparedStatement )
    (conn.prepareStatement("UPDATE TOM1 SET HANDLE = ?
    WHERE PK = ?"));
    ops.setString( 2, jSessionID );
    // using OutputStream to write object data
    OutputStream oStream = oracleBlob.getBinaryOutputStream();
    ObjectOutputStream outStream = new ObjectOutputStream
    (oStream);
    outStream.writeObject(handle); // handle is the Object to be
    saved
    outStream.close();
    conn.commit();
    conn.setAutoCommit(true);
    ops.setBLOB( 1, oracleBlob );
    int rowCount = ops.executeUpdate();
    System.out.println("\n**** Rows affected: ");
    System.out.println(ops.executeUpdate());
    if (rowCount != 0)
    // Commit the transaction:
    System.out.println("\n**** conn.commit() OK...");
    System.out.println("\n**** Handle saved in DB as Blob-type
    OK...");
    conn.commit();
    conn.close();
    else
    System.out.println("\n**** ops.executeUpdate() == 0, Failed
    to update DB");
    conn.close();
    return;
    catch ( SQLException se )
    se.printStackTrace();
    return;
    catch ( Exception e )
    System.out.println(e.toString());
    return;
    System.out.println("\n**** DB update OK...");
    null

    You cannot update Blob column in Adf testing tool as far i think
    check this blog might help you to store images in ADF http://baigsorcl.blogspot.com/2010/09/store-images-in-blob-in-oracle-adf.html

  • Error in updating a blob column

    hi good morning every one,
    first of all i created directory images as 'C:\images'
    then i created table PRICUSTOMERPROOF
    Name                     Null Type        
    CUSTOMERID                    VARCHAR2(50)
    IMAGEID                            NUMBER      
    IDTYP                                 NUMBER      
    IDVALUE                            VARCHAR2(50)
    IDEXPDATE                        TIMESTAMP(6)
    IDIMAGE                            BLOB        
    ACTIVEC                            NUMBER(1)   
    USERR                              VARCHAR2(10)
    DATEE                              TIMESTAMP(6)
    DEFAULTC                        NUMBER(1)   
    CUSTOMERIDENTIFICATIONID      NUMBER 
    then i inserted all the values in the table except IDIMAGE column
    then i tried to update the column with
    DECLARE
      l_bfile  BFILE;
      l_blob   BLOB;
    BEGIN
      SELECT IDIMAGE
      INTO   l_blob
      FROM   PRICUSTOMERPROOF
      WHERE CUSTOMERID = 'Pri29098'
      FOR UPDATE;
      l_bfile := BFILENAME(upper('images'), 'Tulips.jpg');
      DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
      DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
      DBMS_LOB.fileclose(l_bfile);
    END;
    when i execute the codes i am getting
    Error report:
    ORA-22285: non-existent directory or file for FILEOPEN operation
    ORA-06512: at "SYS.DBMS_LOB", line 805
    ORA-06512: at line 12
    22285. 00000 -  "non-existent directory or file for %s operation"
    *Cause:    Attempted to access a directory that does not exist, or attempted
               to access a file in a directory that does not exist.
    *Action:   Ensure that a system object corresponding to the specified
               directory exists in the database dictionary, or
               make sure the name is correct.
    im sure the image directory exists. can any one help me in getting the errors cleared
    thanking you
    prakash

    OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    SYS                            IMAGES                         C:\images                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
    SYS                            ORACLECLRDIR                   D:\PRAKASHFILES\oracleXEpath\app\oracle\product\11.2.0\server\bin\clr                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    SYS                            DATA_PUMP_DIR                  D:\PRAKASHFILES\oracleXEpath\app\oracle\admin\xe\dpdump\                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    SYS                            XMLDIR                         D:\PRAKASHFILES\oracleXEpath\app\oracle\product\11.2.0\server\rdbms\xml                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    SYS                            ORACLE_OCM_CONFIG_DIR          C:/ADE/jaikrish_xe/oracle\ccr\state                   
    these are the directories and i also granted write and read privilege to the user
    then i executed the codes, then
    Error report:
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    ORA-06512: at "SYS.DBMS_LOB", line 928
    ORA-06512: at line 13
    06502. 00000 -  "PL/SQL: numeric or value error%s"

  • BLOB column not updating using automated row processing

    I have fiddled around with creating a simple application to understand how APEX handles images stored in blobs - did a simple app that stores them, gets them, displays them. it all works great.
    so i have this existing table/application that i am trying to add a BLOB column to here's what i did:
    it's a pretty simple form on a table with report application. just one table.
    I added the BLOB to the table (and the other mimetype etc cols as well).
    i added the page items to the form page.
    i basically made everything identical in terms of page item settings and such to the working simple application.
    so here's the problem... when i run the application and update a row, the BLOB column isn't updating. neither are the mimetype or filename columns. the activity date col is.
    and here's another interesting thing. i quickly created another form and report pair on the same table, and when i ran it, it updates the blob col just fine.
    why is my original form not updating it? what can i do to remedy this? any ideas? i've gone though setting by setting for the blob page item and the one that works is identical to the one that doesn't.
    i'm using the automatic row processing to update the table.
    Edited by: moo on Jun 23, 2011 5:33 AM

    Gary,
    The DML processes (and the creation wizards for them) are for use with items having source type Database Column. If your page items don't use this source type, then neither the Automated Row Fetch nor the Automatic Row Processesing (DML) process types will work.
    Scott

  • Updating a blob column using a ResultSet

    Hi,
    I'm using jdeveloper 3.2.3 with a 9i database and the smartupload component to save file in a blob column.
    I'm using the following code
    String sSql0 = "SELECT DOCUMENT.NEXTVAL FROM DUAL";
    oracle.jbo.html.jsp.JSPApplicationRegistry appRegistry = oracle.jbo.html.jsp.JSPApplicationRegistry.getInstance();
    appRegistry.registerApplicationFromPropertyFile(session,"dgpa_bd_BdModule");
    ApplicationModule am = appRegistry.getAppModuleInstance("dgpa_bd_BdModule",request,session);
    ApplicationModuleImpl appMod = (ApplicationModuleImpl)am;
    PreparedStatement stmt1 = appMod.getDBTransaction().createPreparedStatement(sSql0, 1);
    String sSql2 = "SELECT t.* FROM TGTDOCD0 t WHERE IDOCUMEN = 32";
    Statement stmt2 = stmt1.getConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt2.executeQuery(sSql2);
    if (rs.next()) {
    // Initialization
    mySmartUpload.initialize(pageContext);
    // Upload
    mySmartUpload.upload();
    // Add the current file in the DB field
    mySmartUpload.getFiles().getFile(0).fileToField(rs,"gdocumen"); //gdocumen is the blob column
    // Update
    rs.updateRow();
    rs.close();
    stmt2.close();
    But when i run the rs.updateRow() i have the follwing error: java.sql.SQLException: ORA-01008
    what's i'm doing wrong?
    Thanks
    RJC

    Where is the image coming from? Are you getting it from a file? User Upload?
    Here is an example using a procedure in Oracle to upload a file to a blob..: http://technologydribble.info/index.php/category/load-file-into-blob/
    Thank you,
    Tony Miller
    Webster, TX
    You know, um…I used to think that it was awful that life was so unfair. Then I thought, wouldn't it be much worse if life were fair, and all the terrible things that happen to us come because we actually deserve them? So, now I take great comfort in the general hostility and unfairness of the universe
    Anla-shok Marcus from Babylon 5

  • How to update a BLOB column in a table with a file in local machine?

    I have a file (of XML type) in my local machine. I want to update it in a BLOB column of a table in databse server. Can anyone help me in this regard. Appreciate your help.
    Regards
    Walter Nicholas

    user447427 wrote:
    I have a file (of XML type) in my local machine. I want to update it in a BLOB column of a table in databse server. Can anyone help me in this regard.That's the client's job to read data on the client PC (from keyboard/mouse/scanner/file/whatever input) and submit that to the database server for processing and/or storage.
    You cannot expect the server to hack into your PC and lift that data in the file from your disk. Not that is not technically possible. You can wire rockets onto a bicycle to make it go faster, but that's not a wise thing to do. Similarly, it is not a bright idea to ignore the very basics of client-server.
    Bottom line - you need client s/w on your PC to load the content of that file into Oracle. It can be done using SQL*Loader as already suggested. It can be done using a web browser (submitting it via HTTP to web-enabled PL/SQL code). You can use FTP or WebDav and upload into Oracle's XDB (XML database).
    Your requirements will determine what client to use. Once off load? SQL*Loader is very easy to use for loading XML files into the database.

  • BLOB column not updating

    i have two blob columns in my table say b1 and b2, that are used to store the images. the problem is, when i updates B1 column it works but as i try to update the B2 column only it the error 'ORA-100505 Oracle unable to update record' appears.
    but if i updates both the columns then it accepts the value in B2 as well.
    i am working with orcle 8i 6.1. i had faced this proble earlier agaisnt oracle 8, but as shifted to 8i the problem was solved, but it appeared again.
    the other strange problem is,if the coloumn is blank and i call this any coloumn in report the rports aborts displaying message 'unable to read the image format', how ever it was working very much fine earlier. I tried to recreate the column but no success, i also used EMPTY_BLOB() to initialize the coloum but of no avail.
    Any body could help please?
    thanks in advance

    i have two blob columns in my table say b1 and b2, that are used to store the images. the problem is, when i updates B1 column it works but as i try to update the B2 column only it the error 'ORA-100505 Oracle unable to update record' appears.
    but if i updates both the columns then it accepts the value in B2 as well.
    i am working with orcle 8i 6.1. i had faced this proble earlier agaisnt oracle 8, but as shifted to 8i the problem was solved, but it appeared again.
    the other strange problem is,if the coloumn is blank and i call this any coloumn in report the rports aborts displaying message 'unable to read the image format', how ever it was working very much fine earlier. I tried to recreate the column but no success, i also used EMPTY_BLOB() to initialize the coloum but of no avail.
    Any body could help please?
    thanks in advance

  • BLOB Columns Inserts/Updates ???

    Please let me know how SQL*Loader can run updates to just the blob columns without truncation/replace. We want to do incremental updates to the BLOB column without truncation/replace. If this is not possible please let me know any other process which can do this with the best performance we have huge amount of data that needs to be processed. Please let me know .......
    e-mail from the developer.
    Is there something that we or the DBA’s can do to improve performance on these types of inserts/updates with blobs? Currently we are executing batches of inserts/update to the 5 IMAGE_* tables and those are triggering inserts into the IMAGE*_HISTORY tables                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Handle:      user01
    Status Level:      Newbie
    Registered:      Jun 10, 2004
    Total Posts:      252
    Total Questions:      28 (24 unresolved)
    so many questions & so few answers.
    EXTERNAL TABLE is available option
    How fast it is depends upon the SQL & design implementation

  • Getting errors while writing to a BLOB column using PrepareStatement

    Hello,
    I am getting the following errors when I am trying to insert in a BLOB in the oracle 9i database:
    java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error ORA-06512: at line 205 ORA-22297: warning: Open LOBs exist at transaction commit time
    It gets inserted into the BLOB column correctly even after throwing exception.I am using the following code:
    String outputXML = outputXML //Some huge string having a length of 52k
    String pKey = "DATA-WORKATTACH-URL MELLONFINCORP-GSS-CPG E-444!20061130T211932.030 GMT";
    String createDateTime = "20061212T145931.448 GMT";
    String createOpName = "Haque, Nadeem";
    String createOperator = "ADCDTB6";
    String createSystemID = "WFE";
    String insName = "TESt INS";
    String objClass = "Data-WorkAttach-Note";
    String updateDateTime = "20061207T191900.510 GMT";
    String updateOpName = "Haque, Nadeem";
    String updateOperator = "ADCDTB6";
    String updateSystemID = "WFE";
    String label = "This is a test for label";
    String attachDate = "20061207T191900.510 GMT";
    String attachedBy = "Nadeem";
    String attachName = "Nadeem Haque";
    String note = "This is a test note";
    String refObjectKey = "E-438!20061130T211932.030";
    String replicationDate = "20061207T191900.510 GMT";
    try{
    java.sql.PreparedStatement pstmt = null;
    java.sql.Statement stmt = null;
    java.io.OutputStream tempBlobOStream = null;
    oracle.sql.BLOB tempBlob = null;
    javax.naming.Context ctx = new javax.naming.InitialContext();
    tools.findPage("tempWorkPage").putString ("testctx", ctx.toString());     
    javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("jdbc/gswWorkflowReportingData");
    tools.findPage("tempWorkPage").putString ("testds", ds.toString());
    java.sql.Connection conn = ds.getConnection();
    tools.findPage("tempWorkPage").putString ("testconn", conn.toString());
    java.sql.ResultSet lobDetails = null;
         try{
              byte [] ba = outputXML.getBytes();
              String query = "INSERT INTO GSW06U.pc_data_workattach(PZINSKEY,PXCREATEDATETIME,ATTACHDATE,PXUPDATEDATETIME,PXCREATEOPNAME,PXCREATEOPERATOR,PXCREATESYSTEMID,PXINSNAME,PXOBJCLASS,PXUPDATEOPNAME,PXUPDATEOPERATOR,PXUPDATESYSTEMID,PYLABEL,ATTACHEDBY,ATTACHNAME,NOTE,REFOBJECTKEY,ATTACHSTREAM) values(?,to_date(concat(substr(?,1,8),substr(?,10,6)),'YYYYMMDDHH24MISS'),to_date(concat(substr(?,1,8),substr(?,10,6)),'YYYYMMDDHH24MISS'),to_date(concat(substr(?,1,8),substr(?,10,6)),'YYYYMMDDHH24MISS'),?,?,?,?,?,?,?,?,?,?,?,?,?,EMPTY_BLOB())";
              tools.findPage("tempWorkPage").putString ("query", query);
              pstmt = conn.prepareStatement(query);
              pstmt.setString(1, pKey); // Bind PZINSKEY
              pstmt.setString(2, createDateTime); // Bind PZINSKEY
              pstmt.setString(3, createDateTime);
              pstmt.setString(4, attachDate);
              pstmt.setString(5, attachDate);
              pstmt.setString(6, updateDateTime);
              pstmt.setString(7, updateDateTime);
              pstmt.setString(8, createOpName);
              pstmt.setString(9, createOperator);
              pstmt.setString(10, createSystemID);
              pstmt.setString(11, insName);
              pstmt.setString(12, objClass);
              pstmt.setString(13, updateOpName);
              pstmt.setString(14, updateOperator);
              pstmt.setString(15, updateSystemID);
              pstmt.setString(16, label);
              pstmt.setString(17, attachedBy);
              pstmt.setString(18, attachName);
              pstmt.setString(19, note);
              pstmt.setString(20, refObjectKey);
              pstmt.execute(); // Execute SQL statement
              // Retrieve the row just inserted, and lock it for insertion of the LOB columns
              stmt = conn.createStatement();
              lobDetails = stmt.executeQuery("SELECT AttachStream FROM GSW06U.pc_data_workattach WHERE PZINSKEY = '" + pKey + "' FOR UPDATE");
              tools.findPage("tempWorkPage").putString ("idvalue", pKey);
              // Retrieve Blob streams for AttachStream column and load the sample XML
              if( lobDetails.next()) {
              //Get the CLOB from the resultset
              tempBlob = (oracle.sql.BLOB)lobDetails.getBlob(1);
              tools.findPage("tempWorkPage").putString ("pos1", "at pos1");
              // Open the temporary CLOB in readwrite mode, to enable writing
              tempBlob.open(oracle.sql.BLOB.MODE_READWRITE);
              tools.findPage("tempWorkPage").putString ("pos2", "at pos2");
              // Get the output stream to write
              tempBlobOStream = tempBlob.getBinaryOutputStream();
              tools.findPage("tempWorkPage").putString ("pos3", "at pos3");
              // Write the data into the temporary CLOB from the byte array
              tempBlobOStream.write(ba);
              // Flush and close the stream
              tempBlobOStream.flush();
              conn.commit();
              //Close everything
    tempBlobOStream.close();
              tempBlobOStream = null;
              tempBlob.close();
              tempBlob =null;
              lobDetails.close();
              lobDetails = null;
              stmt.close();
              stmt = null;
              pstmt.close();
              pstmt = null;
              conn.close(); // Return to connection pool
              conn = null; // Make sure we don't close it twice
         catch(java.sql.SQLException sqlexp) {
                   tempBlob.freeTemporary();
                   sqlexp.printStackTrace();
                   tools.findPage("tempWorkPage").putString ("SQLException", sqlexp.toString());
         catch(java.lang.Exception exp) {
                   tempBlob.freeTemporary();
                   tools.findPage("tempWorkPage").putString ("InnerException", exp.toString());
                   exp.printStackTrace();
         finally
              if (lobDetails != null) {
              try { lobDetails.close(); } catch (java.sql.SQLException e) { System.out.println(" Error while Freeing Result sets" + e.toString()); }
              lobDetails = null;
              if (stmt != null) {
              try { stmt.close(); } catch (java.sql.SQLException e) {System.out.println(" Error while Freeing java Statement" + e.toString()); }
              stmt = null;
              if (pstmt != null) {
              try { pstmt.close(); } catch (java.sql.SQLException e) {System.out.println(" Error while Freeing java PrepareStatement" + e.toString()); }
              pstmt = null;
              try{
              if (tempBlob != null) {
         // If the BLOB is open, close it
         if (tempBlob.isOpen()) {
         tempBlob.close();
         // Free the memory used by this BLOB
         tempBlob.freeTemporary();
              tempBlob = null;
              catch (Exception ex) { // Trap errors
              System.out.println(" Error while Freeing LOBs : " + ex.toString());
              if (conn != null) {
              try { conn.close(); } catch (java.sql.SQLException e) { System.out.println(" Error while Freeing Connection" + e.toString()); }
              conn = null;
    catch(java.lang.Exception e)
         tools.findPage("tempWorkPage").putString ("LangException", e.toString());
         e.printStackTrace();
    }

    Hello,
    I am getting the following errors when I am trying to
    insert in a BLOB in the oracle 9i database:
    java.sql.SQLException: ORA-00604: error occurred
    at recursive SQL level 1 ORA-06502: PL/SQL: numeric
    or value error ORA-06512: at line 205 ORA-22297:
    warning: Open LOBs exist at transaction commit
    time
    You're doing exactly what the error says, that is committing with an open LOB. Look at the following piece of code: you write in the LOB, you flush it and then commit. There is no closing of the LOB stream before committing.
    Try putting the tempBlobOStream.close() instruction before the commit.
    // Write the data into the temporary CLOB from the
    he byte array
              tempBlobOStream.write(ba);
              // Flush and close the stream
              tempBlobOStream.flush();
    nn.commit();
              //Close everything
    tempBlobOStream.close();

  • Opening Excel Files from DB (blob column)

    My project has implemented a WEBUTIL solution to attach files into the database, view the files stored in the database (in a BLOB column), and remove the files stored in the database.
    Everything has been running smoothly. We are in final testing and have found a couple of interesting scenarios ...
    When a user tries to view an Microsoft Excel 2007 file from our application, the Excel file displays properly (as long as Microsoft Excel isn't already open - outside of our Oracle application). Once the Excel file is viewed, the system will not allow the user back to our application until after the Excel file is closed (we use the start /wait myExcelFile.xls ... command). This works perfectly for us.
    The two scenarios we encounter occur when
    1.) The user has Microsoft Excel open outside of our application and tries to open an Excel file from within our application, or
    2.) The user has the file already open (either from within our application or outside of our application) and then tries to open the file from within our application.
    Let me explain a little further because the above two scenarios are interrelated.
    When a user has Microsoft Excel open (outside of our application), and then clicks the button to open the Excel file, the system will open the file as another window (within Excel). The system will allow the user to navigate back to our application (where as, if Excel is not open outside of our application, the system will not allow the user to navigate back to our application). Once the user navigates back to our application (while the file is still open), the user can click the button to view the file again. At this point, the user is displayed a WUT-105 error message (I assume b/c the system is trying to open a file that is already open).
    I assume the two solutions are the following:
    a.) Do not allow a user to open a file that is already open (not sure how to check this from within Forms ?)
    b.) Do not allow a user to open an Excel file when another EXCEL process is already running (this will avoid allowing the user to naviagate back to our application)
    I don't know if there is a better solution.
    Do you experts have any recommendations?
    We are using Oracle Application Server 10g R2 (10.1.2.0.2), Oracle Database 10g R2 (10.2), and Oracle Developer 10g (10.1.2.0.2)
    I hope this all makes sense.
    Thanks,
    Mike
    Edited by: user639843 on Oct 20, 2008 2:15 PM
    Edited by: user639843 on Oct 20, 2008 2:20 PM

    Thank you, Thank you, Thank you!!!!
    I believe that will work (adding a sequence number to the end of the filename)!
    We do not allow a user to update the file, only view. If a user wants to make a change, they need to remove the existing file (from the database), create a new file (outside of our application), and attach the file in our application (into the database). All updates occur outside of our application - we are not a document authoring system, just a document storage system.
    Once again, many thanks on the solution!
    Mike

  • Writing thumbnail to blob column

    hi i am taking bufferedinputstream as parameter and create thumbnail frm it and stored in blob column but when i retrive that blob column i get blank (black) image as thumbnail plz help me out i have given code here.
    public int addThumbnailDtl(BufferedInputStream localbuf,InputStream inputlocal , String cvdplNo,String fileName,String folderName,String empCode,String prjName,String ext1)
    throws Exception{
                   System.out.println("addThumbnailDtl");
         ConnectionPool ovPool               = null;
              Connection ovCon               = null;     
              Statement ovStmt               = null;
              ResultSet ovResultSet          = null;
         ResultSet ovResultSet1          = null;
              String          sqlStr               = null;
              String          salQuery     = null;
              String          sqlStrUpdate     = null;
              int rowCount =0;
              int chunkSize;
    byte[] binaryBuffer;
    long position                    =1;
              long                    position1 = 1;
    int bytesRead = 0;
              int                    bytesRead1                    = 0;
    int bytesWritten = 0;
    int totbytesRead = 0;
    int totbytesWritten = 0;
              String                    tableName                    = null;
              String                    t_fileValue                    = null;
              String                    t_fileName                    = null;
              String                    vId=null;
              //String size=String.valueOf(fileSize);
              oracle.sql.BLOB image = null;
              BufferedImage thumb = null;
              BufferedOutputStream outputFileOutputStream = null; // newly added 1
              File ImgFile = null;                                        // newly added 3
              // BufferedImage buffimg = null;                              // newly added 4
              String thumbimg               = null;                         // newly added.
              BufferedInputStream inputLocalBuf1     =null;
              binaryBuffer =new byte[8192];
              t_fileValue = "V_FILE_CONTENTS";
                   try{
                   ovPool = new ConnectionPool();
                        ovCon = ovPool.createConnection();
                        ovCon.setAutoCommit(false);
                        ovStmt = ovCon.createStatement();
                        System.out.println("1");
                        salQuery="SELECT V_ID FROM FILEMANAGER_MST "+
                        "WHERE V_PRJ_NAME='"+prjName+"' AND V_CVDPLNO='"+cvdplNo+"'AND V_FILE_NAME='"+fileName+"'";
                        System.out.println("2 Query--"+salQuery);
                        ovResultSet= ovStmt.executeQuery(salQuery);
                        ovResultSet.next();
                        vId=ovResultSet.getString(1);
                        System.out.println("3 Vid --- "+vId);
                   sqlStr = "INSERT INTO FILE_THUMBNAIL VALUES('"+vId+"','"+fileName+"','"+folderName+"','111',EMPTY_BLOB(),'"+ext1+"')";
                   //sqlStr = "INSERT INTO FILEMANAGER_DATA VALUES('"+vId+"','"+fileName+"','"+folderName+"','111',EMPTY_BLOB(),'"+ext1+"')";
                        System.out.println(sqlStr);
                        ovStmt.executeUpdate(sqlStr);
                        System.out.println("Successfully Inserted Record...."+cvdplNo);
                        sqlStrUpdate = " SELECT "+t_fileValue+" FROM FILE_THUMBNAIL WHERE V_ID = '"+vId+"' FOR UPDATE";
                        System.out.println("sqlStrUpdate=> "+sqlStrUpdate);
                        ovResultSet1=ovStmt.executeQuery(sqlStrUpdate);
                        System.out.println("Successful Get Record for Update");
                        if(ovResultSet1 != null){
                             System.out.println("In If Satement");
                             while(ovResultSet1.next()) {
                                  System.out.println("In While Loop");
                                  image = (oracle.sql.BLOB) ovResultSet1.getBlob (t_fileValue);
                                  //oracle.sql.BLOB image = ((OracleResultSet)ovResultSet).getBLOB(t_fileValue);
                                  System.out.println("Transfer into BLOB data");
                                  chunkSize = image.getChunkSize();
                                  System.out.println("1");
                                  binaryBuffer = new byte[chunkSize];
                                  System.out.println("2");
                                  position = 1;
                                  System.out.println("3");
                                  if(inputlocal==null)
                                       System.out.println("blank inputlocal");
                                  BufferedInputStream bInp=new BufferedInputStream(localbuf);
                                  BufferedImage im = ImageIO.read(localbuf);
                                  System.out.println("11");
                                  int tw = 100;//im.getWidth()/5;
                                  System.out.println("12");
                                  int th = 100;//im.getHeight()/5;
                                  System.out.println("5 "+tw+" Height "+th);
                                  thumb = new BufferedImage(tw,th,BufferedImage.TYPE_INT_RGB);
                                  Graphics2D gScaledImg = thumb.createGraphics();
                                  gScaledImg.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                                  BufferedImage img = ImageIO.read(localbuf); // taking inputlocalbuf
                                  gScaledImg.drawImage(img, 0, 0, 100, 100, null);
                                  ByteArrayOutputStream out = new ByteArrayOutputStream();
                                  ImageIO.write(thumb,"jpeg",out);
                                  byte[] buf = out.toByteArray();
                                  ByteArrayInputStream inStream = new ByteArrayInputStream(buf);
                                  while ((bytesRead = inStream.read(binaryBuffer)) != -1)
                                       System.out.println("OOOOOOOOOOOOOOOOOOOOOOOOOO");
                                       bytesWritten = image.putBytes(position, binaryBuffer, bytesRead);
                                       position += bytesRead;
                                       totbytesRead += bytesRead;
                                       totbytesWritten += bytesWritten;
                                  System.out.println("7 "+position1);
                   }catch(SQLException sqlEx){
                                  //System.out.println("SQLException sqlstr=>"+sqlStr);
                                  int errCode = sqlEx.getErrorCode();
                                  String sqlMessage = sqlEx.getMessage();
                                  String sqlState = sqlEx.getSQLState();
                                  System.err.println("Message: " + sqlMessage);
                                  System.err.println("SQL state: " + sqlState);
                                  System.err.println("Error code: " + errCode);
                        }catch(Exception e){
                             System.out.println("Exception sqlstr "+e.getMessage());
                        }finally{
                   try{
                        ovCon.setAutoCommit(true);
                        ovCon.commit();
                        if(ovResultSet != null)
    ovResultSet.close();
    ovResultSet = null;
                   if(ovResultSet1 != null)
    ovResultSet1.close();
    ovResultSet1 = null;
                        if(ovStmt != null)
    ovStmt.close();
                             ovStmt = null;
                        ovPool.close(ovCon);
                        ovCon = null;
                        ovPool = null;
                   catch(Exception err){
                        System.out.println("Already Closing the connection / statement / resultset");
    return 0;
    }

    First, what is a blob column, second, use the code tags

  • Inserting Hashtable into a BLOB column..

    Hi,
    Iam trying to store a hashtable object into a BLOB column..when i try to retrieve
    from hte blob column i get the following exception
    StreamCorruptedException:out of range is 0

    I could insert into database successfully,while retrieving I got this exception.
    I could able to insert and retrieve anyother java objects except Hashtable and
    HashMap...
    also I tried putting Hasttable into a Vector..that also didn'
    t work.
    thanks in advance.
    Muthu
    public void conn(){
    ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
              try {
                   ctx = new InitialContext(ht);
                   javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("WorkFlowDataSource");
                   java.sql.Connection connection = ds.getConnection();
              connection.setAutoCommit(false);
              Statement statement = connection.createStatement();
              rs = statement.executeQuery("select blob_data from test for update");
              while (rs.next()) {
                        myRegularBlob = rs.getBlob("blob_data");
              OutputStream os = ((weblogic.jdbc.common.OracleBlob)myRegularBlob).getBinaryOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
              Hashtable hash = new Hashtable();
              hash.put("1","111111111hgfdhgkdkvalue");
              oos.writeObject(hash);
              oos.flush();
              connection.commit();
              System.out.println("Object inserted into persistence..");
              rs.close();
              statement.close();
              } catch(Exception ex){
                   ex.printStackTrace();
              retrieve();
              public void retrieve(){
              try {
                        ctx = new InitialContext(ht);
                        javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("WorkFlowDataSource");
                        java.sql.Connection connection = ds.getConnection();
                        Statement statement = connection.createStatement();
                        rs = statement.executeQuery("select blob_data from test ");
              while (rs.next()) {
              myRegularBlob = rs.getBlob("blob_data");
              ObjectInputStream oos1 = new ObjectInputStream(os1);
              Hashtable sections = (Hashtable)oos1.readObject();
              System.out.println("Obj retrieved..\n"+sections);
              statement.close();
              rs.close();
              connection.close();
         } catch(Exception ex){
              ex.printStackTrace();
    "Slava Imeshev" <[email protected]> wrote:
    Muthu,
    could you show us how you write/read the hashtable?
    Regards,
    Slava Imeshev
    "Muthu" <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    Iam trying to store a hashtable object into a BLOB column..when i tryto
    retrieve
    from hte blob column i get the following exception
    StreamCorruptedException:out of range is 0

Maybe you are looking for

  • Pass intersection values when drilling through by clicking on a value in a matrix

    I have two SSRS reports. One is acting as a source report and the other as a target report. Both reports give information about "Customer Contact". My source report contains one matrix with the following attributes: Columns: Contact type (Email, Phon

  • My BT experience

    I'd like to share my experiences with BT recently, to see if other customers have had similar struggles: 23rd Oct 2012: Placed an order for a new phoneline connection and broadband. Told the first available Openreach engineer's appointment was for 13

  • Substract days to a date

    Does somebody know a method to substract to a given date (in String format dd/mm/yyyy) a given number of days?? public String restarDias(String fecha, int dias) throws Exception { DateFormat df = DateFormat.getDateInstance(); Date fechaD = df.parse(f

  • IC Broadcast Messaging not working

    Hi SAP Experts, When we open IC broadcast messaging from IC_MANAGER role we get the following screen : Any sort of help will be of great help... Thanks in advance..

  • BI Content for MRS

    Hi Experts, Could you please let me know if there are any standard BI content for MRS? If yes, what are the components/configurations required for these BI content to be activated in ECC? Could you please also share any links for the BI content docum