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 />

Overview of Object Programming<br />

OCCI supports both the associative and navigational style of data access.<br />

Traditionally, third-generation language (3GL) programs manipulate data stored in<br />

a database by using the associative access based on the associations organized by<br />

relational database tables. In associative access, data is manipulated by executing<br />

SQL statements and PL/SQL procedures. OCCI supports associative access to<br />

objects by enabling your applications to execute SQL statements and PL/SQL<br />

procedures on the database server without incurring the cost of transporting data to<br />

the client.<br />

Object-oriented programs that use OCCI can also make use of navigational access<br />

that is a key aspect of this programming paradigm. Applications model their objects<br />

as a set of interrelated objects that form graphs of objects, the relationships between<br />

objects implemented as references (REFs). Typically, an object application that uses<br />

navigational access first retrieves one or more objects from the database server by<br />

issuing a SQL statement that returns REFs to those objects. The application then<br />

uses those REFs to traverse related objects, and perform computations on these<br />

other objects as required. Navigational access does not involve executing SQL<br />

statements except to fetch the references of an initial set of objects. By using OCCI’s<br />

API for navigational access, your application can perform the following functions<br />

on <strong>Oracle</strong> objects:<br />

■ Creating, accessing, locking, deleting, copying and flushing objects<br />

■ Getting references to objects and navigating through the references<br />

This chapter gives examples that show you how to create a persistent object, access<br />

an object, modify an object, and flush the changes to the database server. It<br />

discusses how to access the object using both navigational and associative<br />

approaches.<br />

Working with Objects in OCCI<br />

Many of the programming principles that govern a relational OCCI application are<br />

the same for an object-relational application. An object-relational application uses<br />

the standard OCCI calls to establish database connections and process SQL<br />

statements. The difference is that the SQL statements that are issued retrieve object<br />

references, which can then be manipulated with OCCI’s object functions. An object<br />

can also be directly manipulated as a value (without using its object reference).<br />

Instances of an <strong>Oracle</strong> type are categorized into persistent objects and transient<br />

objects based on their lifetime. Instances of persistent objects can be further divided<br />

3-2 <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!