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

The datatypes of the attribute are mapped to types that are used in <strong>Oracle</strong> object<br />

datatypes, as defined in Table 7–2 on page 7-19.<br />

For each class, two new operators, a getSQLTypeName method, two constructors,<br />

two readSQL methods and two writeSQL methods are generated. The<br />

getSQLTypeName method, the constructor, the readSQL and writeSQL methods<br />

are called by OCCI while unmarshalling and marshalling the object data.<br />

By default, the OTT-generated <strong>C++</strong> class for an object type is derived from the<br />

PObject class and so the generated constructor in the class also derives from the<br />

PObject class. For inherited database types, the class is derived from the parent<br />

type class as is the generated constructor and only the elements corresponding to<br />

attributes not already in the parent class are included.<br />

Class declarations that include the elements corresponding to the database type<br />

attributes and the method declarations are included in the header file generated by<br />

the OTT utility. The method implementations are included in the CPPFILE file<br />

generated by the OTT utility.<br />

The following is an example of the <strong>C++</strong> classes generated by the OTT utility as a<br />

result of this series of steps:<br />

1. Define the types:<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, curr_addr REF ADDRESS,<br />

prev_addr_l ADDRESS_TAB) NOT FINAL;<br />

CREATE TYPE STUDENT UNDER PERSON (school_name CHAR(20));<br />

2. Provide an INTYPE file:<br />

CASE = SAME<br />

MAPFILE = RegisterMappings_3.cpp<br />

TYPE FULL_NAME AS FullName<br />

TRANSLATE first_name as FirstName<br />

last_name as LastName<br />

TYPE ADDRESS<br />

TYPE PERSON<br />

TYPE STUDENT<br />

3. Invoke the OTT utility:<br />

ott userid=scott/tiger intype=demoin_3.typ outype=demoout_3.typ code=cpp<br />

hfile=demo_3.h cppfile=demo_3.cpp<br />

How to Use the Object Type Translator Utility 7-31

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

Saved successfully!

Ooh no, something went wrong!