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.

Persistent Objects<br />

Working with Objects in OCCI<br />

into standalone objects and embedded objects depending on whether or not they<br />

are referenced by way of an object identifier.<br />

A persistent object is an object which is stored in an <strong>Oracle</strong> database. It may be<br />

fetched into the object cache and modified by an OCCI application. The lifetime of a<br />

persistent object can exceed that of the application which is accessing it. Once it is<br />

created, it remains in the database until it is explicitly deleted. There are two types<br />

of persistent objects:<br />

■ A standalone instance is stored in a database table row, and has a unique object<br />

identifier. An OCCI application can retrieve a reference to a standalone object,<br />

pin the object, and navigate from the pinned object to other related objects.<br />

Standalone objects may also be referred to as referenceable objects.<br />

It is also possible to select a referenceable object, in which case you fetch the<br />

object by value instead of fetching it by reference.<br />

■ An embedded instance is not stored in a database table row, but rather is<br />

embedded within another structure. Examples of embedded objects are objects<br />

which are attributes of another object, or objects that exist in an object column<br />

of a database table. Embedded objects do not have object identifiers, and OCCI<br />

applications cannot get REFs to embedded instances.<br />

Embedded objects may also be referred to as nonreferenceable objects or value<br />

instances. You may sometimes see them referred to as values, which is not to be<br />

confused with scalar data values. The context should make the meaning clear.<br />

The following SQL examples demonstrate the difference between these two types of<br />

persistent objects.<br />

Creating Standalone Objects: Example<br />

This code example demonstrates how a standalone object is created:<br />

CREATE TYPE person_t AS OBJECT<br />

(name varchar2(30),<br />

age number(3));<br />

CREATE TABLE person_tab OF person_t;<br />

Objects that are stored in the object table person_tab are standalone objects. They<br />

have object identifiers and can be referenced. They can be pinned in an OCCI<br />

application.<br />

Object Programming 3-3

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

Saved successfully!

Ooh no, something went wrong!