JDBC/MX 5.0 Driver for SQL/MX Programmer's Reference (SQL/MX 2.x)

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 an
SQL/MX Trigger to Delete LOB Data.
See also NULL and Empty BLOB or CLOB Value.
Storing BLOB Data
You can perform operations similar to those used on CLOB columns as those used on BLOB columns by using the Blob
interface. You can:
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.
The details of these operations are discussed in the following topics:
Inserting a BLOB Column Using the Blob Interface
Writing Binary Data to a BLOB Column
Inserting a BLOB Column by Using the PreparedStatement Interface
Inserting a Blob Object by Using the setBlob Method
Inserting a BLOB Column by Using the Blob Interface
When you insert a row containing a BLOB data type, you can insert the row with an "empty" BLOB value before the
column can be updated with real BLOB data. You can insert an empty BLOB value in an SQL/MX database by specifying
EMPTY_BLOB() function for the BLOB column in the insert statement.
The JDBC/MX driver scans the SQL string for the EMPTY_BLOB() function and substitutes the next-available data
locator.
Then, you must 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:
Blob myBlob = null;
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("Select myBlobColumn
from myTable where …For update");
if (rs.next())
myBlob = rs.getBlob(1);
You can now write data to the BLOB column. See Writing Binary Data to a BLOB Column.