10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Updating LOBs<br />

LOB Classes and Methods<br />

When to Use the getChunkSize() Method<br />

Take advantage of the getChunkSize() methods of the Blob and Clob classes to<br />

improve the performance of internal LOB read and write operations. The<br />

getChunkSize() method returns the usable chunk size in bytes for BLOBs and in<br />

characters for CLOBs and NCLOBs. When a read or write is done by using data<br />

whose size is a multiple of the usable chunk size and starts on a chunk boundary,<br />

performance improves. You can specify the chunk size for a LOB column when you<br />

create a table that contains the LOB.<br />

<strong>Call</strong>ing the getChunkSize() method returns the usable chunk size of the LOB.<br />

An application can batch a series of write operations until an entire chunk can be<br />

written, rather than issuing multiple LOB write calls that operate on the same<br />

chunk.<br />

To read through the end of a LOB, use the read() method with an amount of 4 GB.<br />

This avoids the round-trip involved with first calling the getLength() method<br />

because the read() method with an amount of 4 GB reads until the end of the LOB<br />

is reached.<br />

Note: For LOBs which store varying width characters, the<br />

GetChunkSize() method returns the number of Unicode<br />

characters that fit in a LOB chunk.<br />

When to Use the writeChunk() Method<br />

OCCI provides a shortcut to make it more efficient to write data to the end of a<br />

LOB. The writeAppend() methods of the Blob and Clob classes enables an<br />

application to append data to the end of a LOB without first requiring a call to the<br />

getLength() method to determine the starting point for a call to the write()<br />

method.<br />

The following code example demonstrates how to update an internal LOB (in this<br />

example, a CLOB) to empty:<br />

Clob clob(conn);<br />

clob.setEmpty();<br />

stmt->setSQL("UPDATE print_media SET ad_composite = :1<br />

WHERE product_id=6666");<br />

stmt->setClob(1, clob);<br />

stmt->executeUpdate();<br />

Introduction to LOBs 5-15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!