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.

Example OCCI Application<br />

conn, and the database table, PERSON_TAB */<br />

MyPerson *person1 = new(conn, "PERSON_TAB") MyPerson(1,&name1,<br />

addr1->getRef());<br />

/* commit the transaction which results in the newly created object,<br />

person1 being flushed to the server */<br />

conn->commit();<br />

Statement *stmt = conn->createStatement(<br />

"SELECT REF(per) from person_tab per ");<br />

ResultSet *resultSet = stmt->executeQuery();<br />

if (!resultSet->next())<br />

{<br />

cout getRef(1);<br />

Ref joe_ref(joe_refany);<br />

/* de-referencing Ref using ptr() operator. operator -> and operator *<br />

also could be used to de-reference the Ref. As part of de-referencing,<br />

if the referenced object is not found in the application cache, the object<br />

data is retrieved from the server and unmarshalled into Person instance<br />

through MyPerson::readSQL() method. */<br />

MyPerson *joe = joe_ref.ptr();<br />

How to Use the Object Type Translator Utility 7-111

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

Saved successfully!

Ooh no, something went wrong!