1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>SOCI - beyond</title>
</head>
<body>
<p class="banner">SOCI - The C++ Database Access Library</p>
<h2>Beyond SOCI</h2>
<p>As the original name of the library (Simple Oracle Call Interface)
clearly stated, SOCI is intended to be a <i>simple</i> library, targetting the
majority of needs in regular C++ application. We do not claim that
<i>everything</i> can be done with SOCI and it was never the intent of the
library. What is important, though, is that the simplicity of the
library does <i>not</i> prevent the
client applications from reaching into the low-level specifics of each
database backend in order to achieve special configuration or
performance goals.</p>
<p>Most of the SOCI classes have the <code>getBackEnd</code> method,
which
returns the pointer to the actual backend object that implements the
given functionality. The knowledge of the actual backend allows the
client application to get access to all low-level details that are
involved.</p>
<pre class="example">
BLOB b(sql);
OracleSessionBackEnd *sessionBackEnd = static_cast<OracleSessionBackEnd *>(sql.getBackEnd());
OracleBLOBBackEnd *blobBackEnd = static_cast<OracleBLOBBackEnd *>(b.getBackEnd());
OCILobDisableBuffering(sessionBackEnd->svchp_, sessionBackEnd->errhp_, blobBackEnd->lobp_);
</pre>
<p>The above code creates the <code>BLOB</code> object and uses two calls
to the <code>getBackEnd</code> function (on both the <code>Session</code>
and the <code>BLOB</code> objects) to get access to the actual backend
objects. Assuming that it is the <code>"oracle"</code> backend which
is in use, the downcasts allow to access all relevant low-level handles
and use them in the call
to the <code>OCILobDisableBuffering</code> function. This way, the
BLOB handle was configured in a way that the SOCI library itself would
not allow.</p>
<pre class="example">
RowID rid(sql); // sql is a Session object
sql << "select oid from mytable where id = 7", into(rid);
PostgreSQLRowIDBackEnd *rbe = static_cast<PostgreSQLRowIDBackEnd *>(rid.getBackEnd());
unsigned long oid = rbe->value_;
</pre>
<p>The above example retrieves the <code>RowID</code> ("something" that
identifies the
row in the table) from the table and uses the <code>getBackEnd</code>
function to
extract the actual object that implements this functionality. Assuming
that it is the <code>"postgresql"</code> backend which is in use, the
downcast is
performed to use the <code>PostgreSQLRowIDBackEnd</code> interface to
get the actual
OID value that is a physical, low-level implementation of row
identifier on PostgreSQL databases.</p>
<p>In order for any of the above to compile, you have to explicitly <code>#include</code>
the appropriate backend's header file.</p>
<p>Please see the header file related to the given backend to learn what
low-level handles and descriptors are available.</p>
<table class="foot-links" border="0" cellpadding="2" cellspacing="2">
<tr>
<td class="foot-link-left">
<a href="statements.html">Previous (Statements, procedures and transactions)</a>
</td>
<td class="foot-link-right">
<a href="reference.html">Next (Client reference)</a>
</td>
</tr>
</table>
<p class="copyright">Copyright © 2004-2006 Maciej Sobczak, Stephen Hutton</p>
</body>
</html>
|