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.

Working with Collections<br />

Prefetching Complex Objects<br />

After specifying and fetching a complex object, subsequent fetches of objects<br />

contained in the complex object do not incur the cost of a network round-trip,<br />

because these objects have already been prefetched and are in the object cache. Keep<br />

in mind that excessive prefetching of objects can lead to a flooding of the object<br />

cache. This flooding, in turn, may force out other objects that the application had<br />

already pinned leading to a performance degradation instead of performance<br />

improvement.<br />

The SELECT privilege is needed for all prefetched objects. Objects in the complex<br />

object for which the application does not have SELECT privilege will not be<br />

prefetched.<br />

Working with Collections<br />

<strong>Oracle</strong> supports two kinds of collections - variable length arrays (ordered<br />

collections) and nested tables (unordered collections). OCCI maps both of them to a<br />

Standard Template Library (STL) vector container, giving you the full power,<br />

flexibility, and speed of an STL vector to access and manipulate the collection<br />

elements. The following is the SQL DDL to create a VARRAY and an object that<br />

contains an attribute of type VARRAY.<br />

CREATE TYPE ADDR_LIST AS VARRAY(3) OF REF ADDRESS;<br />

CREATE TYPE PERSON AS OBJECT (name VARCHAR2(20), addr_l ADDR_LIST);<br />

Here is the <strong>C++</strong> class declaration generated by OTT:<br />

class PERSON : public PObject<br />

{<br />

protected:<br />

string name;<br />

vector< Ref< ADDRESS > > addr_1;<br />

public:<br />

void *operator new(size_t size);<br />

3-22 <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong> Programmer’s <strong>Guide</strong><br />

Note: If there is insufficient memory in the object cache to hold all<br />

prefetched objects, some objects may not be prefetched. The<br />

application will then incur a network round-trip when those objects<br />

are accessed later.

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

Saved successfully!

Ooh no, something went wrong!