We are facing an issue with updating BLOB column in database table in Oracle. Here’s the problem description:

We have a database table with one of the column datatype as BLOB, the max size specified as 2GB. Inserting a row with the blob column having any size goes through fine. But when we try to update the column (using update statement), it replaces the original blob with an empty blob whenever the size of the byte array exceeds 2000 bytes. It doesn’t throw any exception or error/warning. As a result during subsequent read for the same column fails due to an empty blob. We have simulated and found that whenever the size of the byte array is < 2000 bytes, the updation happens perfectly fine. This is only occurring in case of Oracle and not DB2.

The code for updating the BLOB column is generic and not Oracle specific as shown below:

preparedStatement.setBytes(index, byte[]) : byte[] is the byte array of the BLOB.

Would appreciate if anyone knows of any solution to this problem.