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"

Similar Messages

  • 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.

  • Error in Loading a BLOB Column in Oracle Database from 1 to diff  schema

    Hi ALL,
    I am in a POC where in I have to load a BLOB data from 1 schema to a different schema ie from Staging to Target.
    I load my staging(Oracle Schema ) through Oracle PLSQL. Now I have to load to my ODS.
    I am using the LKM (LKM SQL to Oracle) and IKM (IKM Oracle Incremental Update PLSQL).
    It errors out in the 3rd step 3-Loading-SS_0 Load Data
    The script used and the error message is in the attachment. However if I run the script manually it runs and the Load happens successfully. Also I was able to load the same BLOB objects it the tables were in the same schema(In this case LKM is bypassed).
    Any Thoughts on this?
    The Error I receive is:
    java.lang.NumberFormatException: For input string: "4294967295"
         at java.lang.NumberFormatException.forInputString(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at oracle.jdbc.driver.OracleResultSetMetaData.getPrecision(OracleResultSetMetaData.java:303)
         at com.sunopsis.sql.SnpsQuery.getResultSetParams(SnpsQuery.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    Thanks & Regards,
    Krishna

    Hi,
    Are you at the same database? If yes is better to grant select, at the schemas where is the source, to your Staging Area user.
    Then, at topology, define all physical schemas under the same Data Server.
    If you are at distinct database a good solution is to use a DBLink (KM) because when a SQL to SQL KM is used, the data go thru agent, making a conversion to Java.
    I'm not sure if it can handle LOB's fields... Every time that I needed to use it was in the ways that I described.
    Does it make any sense to you?
    Cezar

  • Error in updating not null column

    hi,
    I am getting the following error when i run the below query,
    SQL> SQL> SQL> SET (a.rate_center_nm,a.rate_center_state_cd,a.load_status_cd) =
    ERROR at line 2:
    ORA-01407: cannot update
    ("MKDM"."MASTER_ADRS_RATE_CENTER_XREF"."LOAD_STATUS_CD") to NULL
    Query
    UPDATE /*+ PARALLEL(a,6) */ master_adrs_rate_center_xref a
    SET (a.rate_center_nm,a.rate_center_state_cd,a.load_status_cd) =
    SELECT /*+ PARALLEL(b,6) */
    b.rate_center_nm
    ,b.rate_center_state_cd
    ,'4'
    FROM
    xref_temp b
    WHERE
    a.mast_pri_address_id = b.mast_pri_address_id
    WHERE EXISTS
    SELECT 1
    FROM
    master_adrs_rate_center_xref b
    ,xref_temp c
    WHERE b.mast_pri_address_id = c.mast_pri_address_id
    Can anyone help me in identifying the error?
    Beneven

    I would change your WHERE EXISTS clause to look exactly like your subquery (except for the column list of course):
    UPDATE master_adrs_rate_center_xref a
    SET   (a.rate_center_nm
          ,a.rate_center_state_cd
          ,a.load_status_cd) =
                 (SELECT b.rate_center_nm
                        ,b.rate_center_state_cd
                        ,'4'
                  FROM   xref_temp b
                  WHERE  a.mast_pri_address_id = b.mast_pri_address_id
    WHERE EXISTS (SELECT 1
                  FROM   xref_temp b
                  WHERE  a.mast_pri_address_id = b.mast_pri_address_id
    ;

  • Error while inserting into blob column through PL/SQL

    Hi All,
    I am trying to insert into column having blob as datatype.
    INSERT INTO imagedb(image_name, content,description) VALUES ('logo.png',
    ?{file 'c:\logo.png'}, 'logo');
    it gives me error Unknown JDBC escape sequence:
    Is there anything wrong in above insert syntax for inserting into BLOB data type.
    Can any body please help me.
    Regards,
    Hiren

    It is not valid SQL as far as Oracle SQL is concerned. I assume that the file construct is suppose to replace that with the contents of the file?
    What happens when the file size exceeds the max length of the SQL command?
    And do you have any idea what will happen to the SQL Shared Pool on Oracle that needs to store the entire SQL command for every single SQL command passed to it? The whole purpose of the Shared Pool is for storing shared SQL. Not non-sharable SQL containing hardcoded values.
    Bind variable are to be used.. if you expect Oracle to perform like only Oracle can.
    And my bet is that you have not even bothered to read [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14249/toc.htm]Oracle® Database Application Developer's Guide - Large Objects guide....

  • 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

  • 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();

  • Insert Blob column in the client errors ClassCastException: oracle.sql.BLOB

    Hi,
    When I try to insert and commit a Blob column(picture) I am getting the following exception.
    Is there any jar I need to add or any other setup I need to do to accept the BLOB column in the olite client database.
    500 Internal Server Error
    javax.faces.FacesException: #{backing_XXPBWorkOrderResultsCreatePGBean.saveButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.sql.BLOB
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
         at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
    Caused by: java.lang.ClassCastException: oracle.sql.BLOB
         at oracle.lite.poljdbc.LiteEmbPreparedStmt.setVal(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
         at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
         at oracle.lite.web.JupPreparedStatement.setObject(Unknown Source)
         at oracle.jbo.server.BaseSQLBuilderImpl.bindUpdateStatement(BaseSQLBuilderImpl.java:1765)
         at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:7345)
    With regareds,
    Kali.
    OSSI.

    Here are examples if inserting into a Blob from text, file, and retrieving a blob.
    Insert into a Blob (Text)
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    public class InsertBlob {
        public static void main(String[] args) throws FileNotFoundException {
            Connection con = null;
            PreparedStatement stmt = null;
            ResultSet rs = null;
            String letterText = "some letter text";
            long id = 100;
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
                try {
                    con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            try {
                stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, EMPTY_BLOB())");
                stmt.setLong(1, id);
                stmt.executeUpdate();
                stmt = con.prepareStatement("SELECT BLOB_DATA FROM BLOB_TABLE WHERE BLOB_ID = ? FOR UPDATE");
                stmt.setLong(1, id);
                rs = stmt.executeQuery();
                if (rs.next()) {
                    try {
                        oracle.lite.poljdbc.BLOB oliteBlob = null;
                        oliteBlob = ((oracle.lite.poljdbc.OracleResultSet) rs).getBLOB(1);
                        byte[] byteLetterText = letterText.getBytes();
                        oliteBlob.putBytes(1, byteLetterText);
                        con.commit();
                    } catch (ClassCastException e) {
                        e.printStackTrace();
                    } finally {
                        rs = null;
                        stmt = null;
                        con.rollback();
                        con = null;
            } catch (SQLException e) {
                e.printStackTrace();
    }Insert Into a Blob (File)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    public class InsertBlobFile {
        public static void main(String[] args) throws FileNotFoundException {
            Connection con = null;
            PreparedStatement stmt = null;
            long id = 200;
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
                try {
                    con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            try {
                stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, ?)");
                stmt.setLong(1, id);
                File fBlob = new File ( "C:\\BLOB_TEST_FILE.TXT" );
                FileInputStream is = new FileInputStream ( fBlob );
                stmt.setBinaryStream (2, is, (int) fBlob.length() );
                stmt.executeUpdate();
                con.commit();
            } catch (SQLException e) {
                e.printStackTrace();
    }Retrieve from Blob (Write to file)
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    public class RetrieveBlob {
        final static int bBufLen = 32 * 1024;
        final static String outFile = "C:\\BLOB_OUTPUT_FILE.TXT";
        public static void main(String[] args) throws IOException {
            Connection con = null;
            PreparedStatement stmt = null;
            ResultSet rs = null;
            try {
                DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
                try {
                    con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
                } catch (SQLException sqle) {
                    sqle.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            try {
                stmt = con.prepareStatement("SELECT * FROM BLOB_TABLE");
                rs = stmt.executeQuery();
                while(rs.next()) {
                    int id = rs.getInt(1);
                    Blob value = rs.getBlob(2);
                    System.out.println(id + " | " + value);
                    writeBlobToFile(value);
            } catch (SQLException e) {
                e.printStackTrace();
        public static long readFromBlob(Blob blob, OutputStream out)
          throws SQLException, IOException {
            InputStream in = blob.getBinaryStream();
            int length = -1;
            long read = 0;
            byte[] buf = new byte[bBufLen];
            while ((length = in.read(buf)) > 0) {
                out.write(buf, 0, length);
                read += length;
            in.close();
            return read;
        public static long writeBlobToFile(Blob blob)
          throws IOException, SQLException {
            long wrote = 0;
            OutputStream fwriter = new FileOutputStream(outFile);
            wrote = readFromBlob(blob, fwriter);
            fwriter.close();
            return wrote;
    }

  • 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

  • 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

  • Error when inserting  file 4KB in a BLOB column.

    Hello,
    I am getting the following error when I am trying to insert a file > 4KB in a
    BLOB column.
    ORA-01461: can bind a LONG value only for insert into a LONG column.
    We are using Weblogic5.1.0 sp10, Oracle 8.0.5 with WL OCI driver.
    There is no change even after setting the following property weblogic.oci.min_bind_size=660
    Please can anyone help?
    Thanks.

    Hello,
    I tried using the following sql stmts to override the NLS_LANG setting on both
    server and client for a session.
    ALTER SESSION SET NLS_LANGUAGE = AMERICAN;
    ALTER SESSION SET NLS_TERRITORY = AMERICA;
    It still gave the same error.
    I tried the same using Oracle thin driver.Even then the same problem.
    As I mentioned earlier, we are using oracle 8.0.5.
    and here is the code I am using for writing BLOB data
    java.sql.PreparedStatement prepstmt = conn.prepareStatement("Update TEST_BLOB
    set BLOBATTACH = ? where IDX =1");
    ByteArrayOutputStream ostream = new ByteArrayOutputStream();
    ObjectOutputStream p = new ObjectOutputStream(ostream);
    p.writeObject(data);
    prepstmt.setBinaryStream(1, new ByteArrayInputStream(ostream.toByteArray()), ostream.size());
    prepstmt.executeUpdate();
    prepstmt.close();
    Any suggestions ?
    Thanks.
    "Slava Imeshev" <[email protected]> wrote:
    Latha,
    You need to make sure you have the same NLS_LANG setting both for the
    client
    and the server.
    Regards,
    Slava Imeshev
    "Latha Pusapaty" <[email protected]> wrote in message
    news:[email protected]...
    I Tried that. But still getting the same exception.
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insertinto a
    LONG column
    at weblogic.db.oci.OciCursor.getCDAException(OciCursor.java:230)
    at weblogic.jdbcbase.oci.Statement.executeUpdate(Statement.java:980)
    atweblogic.jdbc20.pool.PreparedStatement.executeUpdate(PreparedStatement.java:
    47)
    atweblogic.jdbc20.rmi.internal.PreparedStatementImpl.executeUpdate(PreparedSta
    tementImpl.java:54)
    atweblogic.jdbc20.rmi.SerialPreparedStatement.executeUpdate(SerialPreparedStat
    ement.java:55)
    at fictx.TRServlet.doPost(TRServlet.java, Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java, CompiledCode)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java, CompiledCode)
    atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    Compiled Code)
    atweblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java,
    Compiled Code)
    atweblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
    l.java,
    Compiled Code)
    atweblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
    Manager.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,Compiled
    Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,Compiled
    Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Same code is working fine for files less than 4000 bytes.
    Oracle table has only one BLOB column.
    I have set weblogic.oci.selectBlobChunkSize=1200 .
    Where could be the problem?
    Andreas Bittorf <[email protected]> wrote:
    We resolved the problem as following:
    ps = con.prepareStatement
    ("update tq_businessmodel set
    businessmodel=?,lastupdate=?
    "WHERE taskid=?");
    ByteArrayOutputStream ostream = new ByteArrayOutputStream();
    ObjectOutputStream p = new ObjectOutputStream(ostream);
    p.writeObject(businessModel);
    ps.setBinaryStream(1, newByteArrayInputStream(ostream.toByteArray()),
    ostream.size());
    ps.setTimestamp(2,new Timestamp(System.currentTimeMillis()));
    ps.setLong(3,taskid);
    ps.executeUpdate();

  • 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();

  • Error while importing a table with BLOB column

    Hi,
    I am having a table with BLOB column. When I export such a table it gets exported correctly, but when I import the same in different schema having different tablespace it throws error
    IMP-00017: following statement failed with ORACLE error 959:
    "CREATE TABLE "CMM_PARTY_DOC" ("PDOC_DOC_ID" VARCHAR2(10), "PDOC_PTY_ID" VAR"
    "CHAR2(10), "PDOC_DOCDTL_ID" VARCHAR2(10), "PDOC_DOC_DESC" VARCHAR2(100), "P"
    "DOC_DOC_DTL_DESC" VARCHAR2(100), "PDOC_RCVD_YN" VARCHAR2(1), "PDOC_UPLOAD_D"
    "ATA" BLOB, "PDOC_UPD_USER" VARCHAR2(10), "PDOC_UPD_DATE" DATE, "PDOC_CRE_US"
    "ER" VARCHAR2(10) NOT NULL ENABLE, "PDOC_CRE_DATE" DATE NOT NULL ENABLE) PC"
    "TFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS"
    " 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TS_AGIMSAPPOLOLIVE030"
    "4" LOGGING NOCOMPRESS LOB ("PDOC_UPLOAD_DATA") STORE AS (TABLESPACE "TS_AG"
    "IMSAPPOLOLIVE0304" ENABLE STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE L"
    "OGGING STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEF"
    "AULT))"
    IMP-00003: ORACLE error 959 encountered
    ORA-00959: tablespace 'TS_AGIMSAPPOLOLIVE0304' does not exist
    I used the import command as follows :
    imp <user/pwd@conn> file=<dmpfile.dmp> fromuser=<fromuser> touser=<touser> log=<logfile.log>
    What can I do so that this table gets imported correctly?
    Also tell me "whether the BLOB is stored in different tablespace than the default tablespace of the user?"
    Thanks in advance.

    Hello,
    U can either
    1) create a tablespace with the same name in destination where you are trying to import.
    2) get the ddl of the table, modify the tablespace name to reflect the existing tablespace name in destination and run the ddl in the destination database, and run your import command with option ignore=y--> which will ignore all the create errors.
    Regards,
    Vinay

  • How to Update a clob column..it gives error string literal too long

    I am trying to update a clob column of a table but it gives error string literal too long plz tell me what's the issue
    ORA-01704: string literal too long

    Peeyush wrote:
    I am trying to update a clob column of a table but it gives error string literal too long plz tell me what's the issue
    ORA-01704: string literal too longThere's a problem with my car. It won't start. Why won't it start? Please tell me!
    Oh wait, you can't, because I haven't given you nearly enough information...
    In other words, if you would like help in trying to work out where you've gone wrong, you should provide a small enough example of your code that demonstrates the error. We might then actually stand a chance of being able to help you!

Maybe you are looking for

  • How do i change my Apple ID on my iPhone?

    I made a typo when I made my Apple ID on my new iPhone, and as a result can't access anything because i cant verify my account. The incorrect email doen't exsist. I have made a new Apple ID, but the incorrect one keeps coming ap and I cant access it.

  • Make-to-order. Requirement linked to Quotation and not to Sales Order

    After we have changed our Make-To-Order Materials from unvaluated sales order stock to valuated Sales Order Stock we do face a problem with the Requirement for those Sales Orders lines which are started with a Quotation. After running MRP a planned O

  • Business Service 3.2 - get the rows from a flat file into varables?

    Hi masters, I am facing the following issue: There is a flat file and I would like to load its content to a variable. Regards, Slavi

  • Logic to compare date with standard timestamp

    Hi Experts, I want to retrieve the data which is "n" moths old. To compare that I want use only SYSDATE without timestamp. I want to use standard timestamp '23:59:59' along with SYSDATE. The condition should be as below. UPDATE_DATE <= ADD_MONTHS(15/

  • USB Mic Distortion

    I recently bought a Samson G-Track USB microphone, to go with my new Macbook (running Leopard), but seem to get intermittent audio distortion when I record. I have been checking the record levels on the mic and garageband and it's not clipping. If an