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.

The OTT Utility and OCCI Applications<br />

■ By using the MyAddress class instead of the CAddress class as the base class<br />

for database object types that are inherited from ADDRESS. Even though a<br />

derived class is a subtype of MyAddress, the readSQL and writeSQL<br />

methods called are those of the CAddress class.<br />

To use the OTT utility to generate the CAddress class (that you derive the<br />

MyAddress class from), the following clause must be specified in the TYPE<br />

statement:<br />

TYPE ADDRESS GENERATE CAdress AS MyAddress<br />

Example for Extending OTT Classes<br />

Note: When a class is both extended and used as a base class for<br />

another generated class, the inheriting type class and the inherited<br />

type class must be generated in separate files.<br />

Given the database types FULL_NAME, ADDRESS, PERSON, and PFGRFDENT as they<br />

were created before and changing the INTYPE file to include the GENERATE ...<br />

AS clause:<br />

CASE = SAME<br />

MAPFILE = RegisterMappings_5.cpp<br />

TYPE FULL_NAME GENERATE CFullName AS MyFullName<br />

TRANSLATE first_name as FirstName<br />

last_name as LastName<br />

TYPE ADDRESS GENERATE CAddress AS MyAddress<br />

TYPE PERSON GENERATE CPerson AS MyPerson<br />

TYPE STUDENT GENERATE CStudent AS MyStudent<br />

The following <strong>C++</strong> source file (with the extension .cpp) is generated by the OTT<br />

utility:<br />

#ifndef MYFILENAME_ORACLE<br />

# define MYFILENAME_ORACLE<br />

#ifndef OCCI_ORACLE<br />

# include <br />

#endif<br />

How to Use the Object Type Translator Utility 7-51

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

Saved successfully!

Ooh no, something went wrong!