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.

A Sample OCCI Application<br />

void *operator new(size_t size);<br />

void *operator new(size_t size, const Session* sess, const string& table);<br />

string getSQLTypeName(size_t size);<br />

(void *ctx) : (ctx) { };<br />

static void *readSQL(void *ctx);<br />

virtual void readSQL(AnyData& stream);<br />

static void writeSQL(void *obj, void *ctx);<br />

virtual void writeSQL(AnyData& stream);<br />

}<br />

In this structure, all the variables are the same as in the simple object case.<br />

parentTypename refers to the name of the parent type, that is, the class name of<br />

the type from which typename inherits.<br />

A Sample OCCI Application<br />

Following is a sample OCCI application that uses some of the features discussed in<br />

this chapter.<br />

First we list the SQL DDL and then the OTT mappings.<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);<br />

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

Let us assume OTT generates FULL_NAME, ADDRESS, PERSON, and PFGRFDENT<br />

class declarations in demo.h. The following sample OCCI application will extend<br />

the classes generated by OTT and will add some user defined methods.<br />

/************************* myDemo.h *****************************************/<br />

#include demo.h<br />

// declarations for the MyFullName class.<br />

class MyFullname : public FULLNAME {<br />

public:<br />

MyFullname(string first_name, string last_name);<br />

void displayInfo();<br />

Object Programming 3-29

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

Saved successfully!

Ooh no, something went wrong!