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.

Example OCCI Application<br />

Example OCCI Application<br />

This OCCI application example extends the OTT-generated <strong>C++</strong> classes and<br />

translates inherited object types. Each class in this application contains a constructor<br />

to initialize class objects and a method to display the values assigned to the<br />

attributes of the object. The MyPerson class also has a method to change the curr_<br />

addr attribute. All the classes here are derived from the generated classes.<br />

Create the needed types and tables for the OCCI application as illustrated in the<br />

following code example:<br />

connect scott/tiger<br />

create type full_name as object (first_name char(20), last_name char(20));<br />

create type address as object (state char(20), zip char(20));<br />

create type address_tab as varray(3) of ref address;<br />

create type person as object (id number, name full_name,<br />

curr_addr ref address, prev_addr_l address_tab) not final;<br />

create type student under person (school_name char(20));<br />

/* tables needed in the user-written occi application */<br />

create table addr_tab of address;<br />

create table person_tab of person;<br />

create table student_tab of student;<br />

The INTYPE file provided to the OTT utility contains the following information:<br />

CASE = SAME<br />

MAPFILE = registerMappings.cpp<br />

TYPE FULL_NAME GENERATE CFullName AS MyFullName<br />

HFILE=cfullname.h<br />

CPPFILE=cfullname.cpp<br />

TRANSLATE first_name as FirstName<br />

last_name as LastName<br />

TYPE ADDRESS GENERATE CAddress AS MyAddress<br />

HFILE=caddress.h<br />

CPPFILE=caddress.cpp<br />

How to Use the Object Type Translator Utility 7-85

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

Saved successfully!

Ooh no, something went wrong!