|Oracle9i Application Developer's Guide - Large Objects (LOBs)
Release 1 (9.0.1)
Part Number A88879-01
Frequently Asked Questions about LOBs, 5 of 12
When must I use EMPTY_BLOB() and EMBPTY_CLOB()? I always thought it was mandatory for each insert of a CLOB or BLOB to initialize the LOB locator first with either EMPTY_CLOB() or EMPTY_BLOB().
In Oracle8i release 8.1.5, you can initialize a LOB with data via the insert statement as long as the data is <4K. This is why your insert statement worked. Note that you can also update a LOB with data that is <4K via the UPDATE statement. If the LOB is larger than 4K perform the following steps:
Note the following:
From java we want to insert a complete object with a BLOB attribute into an Oracle8.1.5 object table. The problem is - in order to do that - we have somehow to initialize the blob attribute with EMPTY_BLOB(). Is there any way to initialize the BLOB attribute with EMPTY_BLOB() in java? What I am doing at the moment is:
First I insert the object with null in the BLOB attribute. Afterwards I update the object with an EMPTY_BLOB(), then select it again, get the BLOB locator and finally write my BLOB.
Is this the only way it works ? Is there a way to initialize the BLOB directly in my toDatum method of the Custom Datum interface implementation?
Here is the SQLJ equivalent...
and use myblob in your code wherever the BLOB needed to be initialized to null.
See also the question and answer under the section, "JDBC, JPublisher and LOBs", "How Do I setData to EMPTY_BLOB() Using JPublisher?"