JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2.1

Replacing Clob Objects
You can replace Clob objects in the following ways:
Use the EMPTY_CLOB() function to replace the Clob object with the empty Clob object,
then insert new data as described under Inserting CLOB Columns by Using the Clob Interface.
Use the PreparedStatement.setAsciiStream() or setCharacterStream() method
to replace the existing Clob object with new CLOB data.
Use the setClob or updateClob method to replace the existing CLOB objects as explained
under Inserting a Clob Object with the setClob Method and Updating Clob Objects with the
updateClob Method.
Deleting CLOB Data
To delete CLOB data, the JDBC application uses the SQL DELETE statement to delete the row in the
base table.
When the row containing the CLOB column is deleted by the JDBC application, the corresponding
CLOB data is automatically deleted by the delete trigger associated with the base table. For
information about triggers, see Using SQL/MX Triggers to Delete LOB Data.
See also “NULL and Empty BLOB or Empty CLOB Value” (page 63).
Storing BLOB Data
“Inserting a BLOB Column by Using the Blob Interface (page 60)
“Writing Binary Data to a BLOB Column (page 61)
“Inserting a BLOB Column by Using the PreparedStatement Interface (page 61)
“Inserting a Blob Object by Using the setBlob Method” (page 61)
Perform operations on BLOB columns that are similar to those operations used on CLOB columns.
Use the EMPTY_BLOB() function in the insert statement to create an empty BLOB column in
the database.
Use setBinaryStream method of the Blob interface to obtain the InputStream to read
BLOB data.
Use getBinaryStream method of the Blob interface to obtain the OutputStream to write
BLOB data.
Use setBinaryStream of the PreparedStatement interface to write the data to the BLOB
column.
Inserting a BLOB Column by Using the Blob Interface
When you insert a row containing a BLOB data type, you can insert the row using an empty BLOB
value before the column can be updated with real BLOB data. To insert an empty BLOB value in
an SQL/MX database, specify EMPTY_BLOB() function for the BLOB column in the insert statement.
The Type 4 driver scans the SQL string for the EMPTY_BLOB() function and substitutes the
next-available data locator.
NOTE:
The EMPTY_BLOB() function is an HP NonStop specific function and might not work on other
databases.
Do not use the EMPTY_BLOB() function when using the PreparedStatement interface.
Then, obtain the handle to the empty BLOB column by selecting the BLOB column for update. The
following code illustrates how to obtain the handle to an empty BLOB column:
60 Working with BLOB and CLOB Data