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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Overview of Complex Object Retrieval<br />

Retrieving Complex Objects<br />

An OCCI application can achieve COR by setting the appropriate attributes of a<br />

Ref before dereferencing it using the following methods:<br />

// prefetch attributes of the specified type name up to the the specified depth<br />

Ref::setPrefetch(const string &typeName, unsigned int depth);<br />

// prefetch all the attribute types up to the specified depth.<br />

Ref::setPrefetch(unsigned int depth);<br />

The application can also choose to fetch all objects reachable from the root object by<br />

way of REFs (transitive closure) to a certain depth. To do so, set the level parameter<br />

to the depth desired. For the preceding two examples, the application could also<br />

specify (PO object REF, OCCI_MAX_PREFETCH_DEPTH) and (PO object<br />

REF, 1) respectively to prefetch required objects. Doing so results in many<br />

extraneous fetches but is quite simple to specify, and requires only one database<br />

server round-trip.<br />

As an example for this discussion, consider the following type declaration:<br />

CREATE TYPE customer(...);<br />

CREATE TYPE line_item(...);<br />

CREATE TYPE line_item_varray as VARRAY(100) of REF line_item;<br />

CREATE TYPE purchase_order AS OBJECT<br />

( po_number NUMBER,<br />

cust REF customer,<br />

related_orders REF purchase_order,<br />

line_items line_item_varray)<br />

The purchase_order type contains a scalar value for po_number, a VARRAY of<br />

line_items, and two references. The first is to a customer type and the second is<br />

to a purchase_order type, indicating that this type may be implemented as a<br />

linked list.<br />

When fetching a complex object, an application must specify the following:<br />

■ A reference to the desired root object<br />

■ One or more pairs of type and depth information to specify the boundaries of<br />

the complex object. The type information indicates which REF attributes should<br />

be followed for COR, and the depth level indicates how many levels deep those<br />

links should be followed.<br />

In the case of the purchase_order object in the preceding example, the<br />

application must specify the following:<br />

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

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

Saved successfully!

Ooh no, something went wrong!