📄 ociwrap.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content>
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>OCI Wrapper</title>
</head>
<body bgcolor="#FFFFC0" text="#000000" link="#0000FF"
vlink="#800080" alink="#FF00FF">
<h1>OCI++ (Oracle Call Interface ++)</h1>
<h3>Author: <a href="mailto:j.hatcher@virgin.net">John Hatcher</a></h3>
<p>Last updated: <!--webbot bot="Timestamp" startspan
s-type="EDITED" s-format="%m/%d/%y" -->01/23/00<!--webbot
bot="Timestamp" i-checksum="12270" endspan --> </p>
<p><!--webbot bot="HTMLMarkup" startspan --><!-- Start of TheCounter.com Code -->
<SCRIPT><!--
s="na";c="na";j="na";f=""+escape(document.referrer)
//--></SCRIPT>
<SCRIPT language="javascript1.2"><!--
s=screen.width;v=navigator.appName
if (v != "Netscape") {c=screen.colorDepth}
else {c=screen.pixelDepth}
j=navigator.javaEnabled()
//--></SCRIPT>
<SCRIPT><!--
function pr(n) {document.write(n,"\n");}
NS2Ch=0
if (navigator.appName == "Netscape" &&
navigator.appVersion.charAt(0) == "2") {NS2Ch=1}
if (NS2Ch == 0) {
r="&size="+s+"&colors="+c+"&referer="+f+"&java="+j+""
pr("<A HREF=\"http://www.TheCounter.com\" TARGET=\"_top\"><IMG")
pr("BORDER=0 SRC=\"http://c1.thecounter.com/id=330362"+r+"\"></A>")}
//--></SCRIPT>
<NOSCRIPT><A HREF="http://www.TheCounter.com" TARGET="_top"><IMG
SRC="http://c1.thecounter.com/id=330362" BORDER=0></A>
</NOSCRIPT>
<!-- End of TheCounter.com Code --><!--webbot
bot="HTMLMarkup" endspan --></p>
<ul type="disc">
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Prerequesites">Prerequesites</a></li>
<li><a
href="http://freespace.virgin.net/j.hatcher/overview.htm">Overview</a></li>
<li><a href="#OCI Wrapper Usage">OCI++ usage</a></li>
<li><a href="#Database Co-ordinators">Database co-ordinators</a></li>
<li><a href="#Data Types">Datatypes</a></li>
<li><a
href="http://freespace.virgin.net/j.hatcher/abstract.htm">Abstract
Example</a></li>
<li><a href="#Download">Download</a></li>
</ul>
<h2><a name="Introduction"></a>Introduction</h2>
<p>The Oracle Call Interface (OCI) is the fastest and most
flexible way of accessing data in an Oracle database. However,
the interface to OCI is very complex and a lack of understanding
leaves it open to misuse. These problems have been addressed by
the creation of this small lightweight C++ API that sits on top
of OCI. This API provides an intuitive OO approach to
manipulating Oracle Objects. What I present here, by way of a UML
design, is how Oracle objects can be used seamlessly within C++.</p>
<hr>
<h3><a name="Prerequesites"></a>Prerequisites</h3>
<p>I make the following assumptions about what the user must be
familiar with:-</p>
<ul type="disc">
<li>Have an understanding of the UML notation.</li>
<li>Know what an object is in Oracle.</li>
<li>Have a fairly good understanding of C++, and to know what
STL (Standard Template Library) is.</li>
</ul>
<hr>
<h2><a name="OCI Wrapper Usage"></a>OCI++ Usage</h2>
<p>There are a few things to remember when using OCI++:</p>
<ul>
<li>A session to a database must have been established.</li>
<li>All database activity is carried out in a transaction.</li>
<li>All OCI types are encapsulated by a class and prefixed
with a 'C', e.g. OCIRef becomes COCIRef.</li>
</ul>
<h3><a name="Database Co-ordinators"></a>Database Co-ordinators</h3>
<table border="1" bgcolor="#FFFF00" bordercolordark="#000000">
<tr>
<td>COCISession</td>
<td>Establishes a connection to an Oracle Database</td>
</tr>
<tr>
<td>COCITransaction</td>
<td>Carries out a unit of work on the database</td>
</tr>
<tr>
<td>COCIStatement</td>
<td>Passes SQL statements to database.</td>
</tr>
<tr>
<td>COCITable</td>
<td>Encapsulation of Oracle Table</td>
</tr>
<tr>
<td>COCIType</td>
<td>Encapsulation of Oracle Type</td>
</tr>
<tr>
<td>COCICache</td>
<td>Holds a cache of objects per session</td>
</tr>
</table>
<h3><a name="Data Types"></a>Data Types</h3>
<table border="1" bgcolor="#FFFF00">
<tr>
<td><strong>COCI representation</strong></td>
<td><strong>OCI representation</strong></td>
</tr>
<tr>
<td>COCIDate</td>
<td>OCIDate</td>
</tr>
<tr>
<td>COCILob</td>
<td>OCI Lobs (i.e. CLob, BLob, BFile)</td>
</tr>
<tr>
<td>COCINumber</td>
<td>OCINumber</td>
</tr>
<tr>
<td>COCIObject</td>
<td>OCIObject</td>
</tr>
<tr>
<td>COCIRef</td>
<td>OCIRef</td>
</tr>
<tr>
<td>COCIString</td>
<td>OCIString</td>
</tr>
<tr>
<td>COCIColl</td>
<td>OCIColl - collection base class</td>
</tr>
<tr>
<td>COCINestedTable</td>
<td>Nested Table</td>
</tr>
<tr>
<td>COCIVarray</td>
<td>VArray</td>
</tr>
</table>
<h3><a name="Miscellaneous"></a>Miscellaneous</h3>
<table border="1" bgcolor="#FFFF00">
<tr>
<td>COCITimeSpan</td>
<td>Used to calculated times between dates</td>
</tr>
<tr>
<td>COCIBinary</td>
<td>Utility class to manipulate raw data</td>
</tr>
<tr>
<td>COCIAttribute</td>
<td>Acts like a proxy data type</td>
</tr>
</table>
<hr>
<h2><a name="Download"></a>Download</h2>
<h3>Software requirements</h3>
<p>Platforms supported:</p>
<ul>
<li>Windows NT 4.0</li>
<li>Sun Solaris</li>
</ul>
<p>Compilers supported</p>
<ul>
<li>Visual C++ 6.0 with Visual Studio 6 Service Pack 3.0.</li>
<li>Workshop 4.2 for Solaris (You will need a freeware
version of STL for solaris found at : <a
href="http://www.stlport.org/">http://www.stlport.org/</a>
)</li>
</ul>
<p>Oracle Server Version 8.0.4 (Should be upwardly compatible
with Oracle 8i)</p>
<p><a href="oci++.zip"></a>Download:<font size="4"
face="Courier New"> </font><a
href="http://freespace.virgin.net/j.hatcher/oci++.zip"><font
size="4" face="Courier New">oci++.zip</font></a><font size="4"
face="Courier New"> <<strong>Now with Source code!!</strong>></font></p>
<h2>Revision History</h2>
<ul>
<li>Tidied up ocimain - made sure the examples actually
work!! </li>
<li>Removed anomaly with creating type objects (now uses
default schema)</li>
<li>Used reference to sessions rather than pointer. </li>
<li>Removed dependency upon ObjectSpace (worked around bug in
VC++)</li>
<li>Tightened up ref usage and object usage. </li>
<li>Used UML to demonstrate a working example</li>
<li>Changed set_attr_value/get_attr_value to set/get
respectively</li>
<li>Changed define_by_pos to define</li>
<li>Changed bind_by_pos/bind_by_name to bind (C++ can handle
polymorphism!!)</li>
<li>Added a readme.txt (initially on how to build the demo
program)</li>
<li>Removed a lot of memory leaks (most often associated with
OCIHandleAlloc)</li>
<li>Implemented proper copy constructor for COCIObject (i.e.
no longer shares instances)</li>
<li>Changed the name from OCIWRAP to OCI++</li>
<li>Added null indicator to COCIString, COCINumber</li>
<li>Removed inefficient attribute name retrieval</li>
<li>Added demonstration of multi-threading</li>
<li>Added complex retrieval class</li>
<li>Built using Visual C++ 6.0.</li>
<li>Included source code.</li>
</ul>
<h2>Disclaimer</h2>
<p>This code is given away free and I accept no responsibility
for consequences caused by loss of data, system crashes, etc.
etc. I reserve the right to change the code at any time. If you
like/dislike/have queries about oci++, etc., etc., then send me
an email.</p>
<p>Many people have asked for the source code to OCI++. At long
last, I've decided to distribute it so that others trying to
understand OCI can benefit. For this, all I ask is, if you find
the code useful then I would be most grateful if you could show
your appreciation for my work, by sending me some cash reward.
This reward should take the form of UK pounds, and can be either
in the form of a cheque or in cash. Make cheques payable to John
Hatcher, and send them to:- 57 Berrylands Road, Surbiton, Surrey,
KT5 8PB. </p>
<p>Cheers! (And now for something completely different...?)</p>
<p> </p>
<hr>
<p><a mailto="j.hatcher@virgin.net"></a>Email: <a
href="mailto:j.hatcher@virgin.net">j.hatcher@virgin.net</a></p>
<p> </p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -