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 Objects in OCCI<br />

Transient Objects<br />

Creating Embedded Objects: Example<br />

This code example demonstrates how an embedded object is created:<br />

CREATE TABLE department<br />

(deptno number,<br />

deptname varchar2(30),<br />

manager person_t);<br />

Objects which are stored in the manager column of the department table are<br />

embedded objects. They do not have object identifiers, and they cannot be<br />

referenced. This means they cannot be pinned in an OCCI application, and they also<br />

never need to be unpinned. They are always retrieved into the object cache by value.<br />

A transient object is an instance of an object type. Its lifetime cannot exceed that of<br />

the application. The application can also delete a transient object at any time.<br />

The Object Type Translator (OTT) utility generates two operator new methods<br />

for each <strong>C++</strong> class, as demonstrated in this code example:<br />

class Person : public PObject {<br />

.<br />

.<br />

.<br />

public:<br />

dvoid *operator new(size_t size); // creates transient instance<br />

dvoid *operator new(size_t size, Connection &conn, string table);<br />

// creates persistent instance<br />

}<br />

The following code example demonstrates how a transient object can be created:<br />

Person *p = new Person();<br />

Transient objects cannot be converted to persistent objects. Their role is fixed at the<br />

time they are instantiated.<br />

See Also:<br />

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

■ <strong>Oracle</strong>9i Database Concepts for more information about objects

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

Saved successfully!

Ooh no, something went wrong!