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.

OCCI Demonstration Programs<br />

occidml.cpp<br />

The following code example demonstrates how to perform insert, select, update,<br />

and delete operations of a table row by using OCCI:<br />

/**<br />

* occidml - To exhibit the insertion, Selection, updating and deletion of<br />

* a row through OCCI.<br />

*<br />

* Description<br />

* Create a program which has insert, select, update & delete as operations.<br />

* Perform all these operations using OCCI interface.<br />

*/<br />

#include <br />

#include <br />

using namespace oracle::occi;<br />

using namespace std;<br />

class occidml<br />

{<br />

private:<br />

Environment *env;<br />

Connection *conn;<br />

Statement *stmt;<br />

public:<br />

occidml (string user, string passwd, string db)<br />

{<br />

env = Environment::createEnvironment (Environment::DEFAULT);<br />

conn = env->createConnection (user, passwd, db);<br />

}<br />

~occidml ()<br />

{<br />

env->terminateConnection (conn);<br />

Environment::terminateEnvironment (env);<br />

}<br />

/**<br />

* Insertion of a row with dynamic binding, PreparedStatement functionality.<br />

*/<br />

A-32 <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong> Programmer’s <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!