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.

Optimizing Performance<br />

Advanced Relational Techniques<br />

When you provide data for bind parameters by the setxxx methods in<br />

parameterized statements, the values are copied into an internal data buffer, and the<br />

copied values are then provided to the database server for insertion. This data<br />

copying may be expensive, especially if large strings are involved. Also, for each<br />

new value, the string is reallocated, so there may be memory management overhead<br />

in repeated allocation and deallocation of strings.<br />

For these reasons, OCCI provides several methods to help counter these<br />

performance drains. These methods are:<br />

■ setDataBuffer<br />

■ executeArrayUpdate<br />

■ next (of the ResultSet class)<br />

setDataBuffer Method<br />

For high performance applications, OCCI provides the setDataBuffer method<br />

whereby the data buffer is managed by the application. The following example<br />

shows the setDataBuffer method:<br />

void setDataBuffer(int paramIndex,<br />

void *buffer,<br />

Type type,<br />

sb4 size,<br />

ub2 *length,<br />

sb2 *ind = NULL,<br />

ub2 *rc = NULL);<br />

The following parameters are used in the previous method example:<br />

■ paramIndex: Parameter number<br />

■ buffer: Data buffer containing data<br />

■ type: Type of the data in the data buffer<br />

■ size: Size of the data buffer<br />

■ length: Current length of data in the data buffer<br />

■ ind: Indicator information. This indicates whether the data is NULL or not. For<br />

parameterized statements, a value of -1 means a NULL value is to be inserted.<br />

For data returned from callable statements, a value of -1 means NULL data is<br />

retrieved.<br />

Relational Programming 2-27

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

Saved successfully!

Ooh no, something went wrong!