⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 otl3_connect_class.htm

📁 ISO_C++:C++_OTL开发文档
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<br>
</font></div>
<ul>
  <a name="auto_commit"></a>The auto_commit parameter in this function
is
used for setting the connection "auto-commit" mode. This means that
every
single SQL statement, executed in the connection, will be automatically
committed. This auto-commit mode has nothing to do with the <a
 href="otl3_stream_class.htm#set_commit">otl_stream
auto-commit</a> mode. In order to set the mode to "auto-commit", the
auto_commit
parameter needs to be set to 1. By default, it is 0, meaning that
"auto-commit"
is off.
  <p>In Oracle 7, ODBC and DB2-CLI, this mode is called "auto-commit".
In
Oracle 8/8i/9i, it is called "commit-on-success." It is not quite clear
why in Oracle 8 the term was changed to "commit-on-success" and pushed
from the level of the connection down to the level of the SQL statement
execution.</p>
</ul>
<ul>
  <li> <a name="attach7"></a>Log on / connect to / attach to the
primary
database
connection, which was made in Pro*C/C++ or any other third-party
library.
This function works for <b><i>OTL/OCI7</i></b> only, and it helps to
make
transition from the legacy environment to the OTL environment smoother.
See also example <a href="otl3_ex58.htm">58</a>.</li>
</ul>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <tt>void
rlogon(Lda_Def* lda);</tt>
<ul>
  <li> <a name="ext_logon_odbc"></a>Log on / connect to / attach to
the
primary
database connection, which was made in straight ODBC, DB2-CLI, or any
other
third-party (ODBC, or DB2-CLI based) library. This function works for <b><i>OTL/ODBC,
DB2-CLI</i></b> only, and it helps to make transition from the legacy
environment
to the OTL environment smoother.</li>
</ul>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void rlogon(HENV henv,
//
environment handle</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
HDBC hdbc, // database connect handle</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const int auto_commit=0 // connect auto-commit mode</tt>
<br>
<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);<br>
</tt>
<ul>
  <li> <a name="logon_odbc_unicode"></a>Log on / connect to the
database (DSN / database alias). This function works for <b><i>OTL/ODBC,
DB2-CLI</i></b> only, when Unicode ODBC driver functions are enabled
(via<span style="font-family: monospace;"> #define UNICODE, #define
_UNICODE). </span>The
function allows Unicode user names, passwords, and DSNs to be passed
into the ODBC layer.<span style="font-family: monospace;"><br>
    </span></li>
</ul>
<span style="font-family: monospace;">#if defined(<a
 href="otl3_compile.htm#OTL_UNICODE_EXCEPTION_AND_RLOGON">OTL_UNICODE_EXCEPTION_AND_RLOGON</a>)<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; void rlogon(const <a
 href="otl3_compile.htm#OTL_UNICODE_CHAR_TYPE">OTL_UNICODE_CHAR_TYPE</a>*
username, // user name<br>
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const OTL_UNICODE_CHAR_TYPE* passwd, // password<br>
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const OTL_UNICODE_CHAR_TYPE* dsn, // data source name<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int auto_commit=0 // connect
auto-commit mode<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
);<br>
<br>
#endif<br>
</span><tt><br>
</tt>
<ul>
  <li><a name="ext_otl_connect_odbc"></a>General constructor: connect
to
the
primary database connection, which was made in straight ODBC, DB2-CLI,
or any other third-party (ODBC, or DB2-CLI based) library. This
function
works for <b><i>OTL/ODBC, DB2-CLI</i></b> only, and it helps to make
transition
from the legacy environment to the OTL environment smoother.</li>
</ul>
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; otl_connect(HENV henv, // environment handle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HDBC hdbc, // database connect handle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int auto_commit=0 // connect auto-commit mode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</pre>
<ul>
  <li> <a name="attach8"></a>Log on / connect to / attach to the
primary
database
connection, which was made in Pro*C/C++ or any other third-party
library.
This function works for <b><i>OTL/OCI8/8i/9i/10g/11g</i></b> only, and
it
helps
to make integration of OTL/OCI8/8i/9i/10/g/11g and the Pro*C/C++
environment
smooth
and easy. In order to use this function in the Pro*C/C++ environment,
#define
OTL_ORA8_PROC needs to be set at the beginning of the program. For more
detail, see example <a href="otl3_ex59.htm">59</a></li>
  <p><i>envhp</i> is a pointer to the OCI8/8i/9i/10g/11g environment
handle,
which
needs to be obtained by calling the <i>SQLEnvGet</i> function. <br>
  <i>svchp </i>is a pointer to the OCI8/8i/9i/10g/11g service context
handle,
which needs to be obtained by calling the <i>SQLSvcCtxGet</i> function.</p>
</ul>
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void rlogon(OCIEnv* envhp, OCISvcCtx* svchp);<br><br></pre>
<ul>
  <li><a name="rlogon_xa"></a><b><i>OTL/OCI8/8i/9i/10g/11g, </i></b>connect
to the database and set the following connection attributes that are
required by the Oracle XA Library: server external name, server
internal name. <br>
    <br>
    <pre>&nbsp;void rlogon(const char* connect_str,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int aauto_commit=0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const char* xa_server_external_name=0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const char* xa_server_internal_name=0,<br>#if defined(<a
 href="otl3_compile.htm#OTL_ORA_OCI_ENV_CREATE">OTL_ORA_OCI_ENV_CREATE</a>)<br>             bool threaded_mode=false<br>#endif<br>            );<br></pre>
  </li>
</ul>
<ul>
  <li> <a name="logoff"></a>Logs off / disconnects from the database.
In
case
if the primary connection was done in Pro*C/C++ (OTL/OCIx), this
function
just detaches from that connection without actually disconnecting from
the database.</li>
</ul>
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void logoff(void);</pre>
<ul>
  <li> <a name="attach_detach"></a>Attach to / detach from Oracle (<b><i>OTL/OCI8/8i/9i/10g/11g</i></b>
only). These functions are wrappers around the ServerAttach and
ServerDetach
functions of the OCI8/9/10/11. The main reason to have separate
functions to
attach
to the server and then begin a session is performance. For more detail,
see Oracle's regular manuals. These functions, along with the <a
 href="#session_begin">session_begin</a>
and <a href="#session_end">session_end</a> functions, could be used
for
implementing a connection management mechanism that is more efficient
than
the traditional connection pooling. See also example <a
 href="otl3_ex60.htm">60</a>.<br>
  </li>
</ul>
<pre>&nbsp;&nbsp;&nbsp;&nbsp; <a name="server_attach"></a>void server_attach(const char* tnsname=0,&nbsp;<br>                           const char* xa_server_external_name=0,<br>                           const char* xa_server_internal_name=0,<br>#if defined(<a
 href="otl3_compile.htm#OTL_ORA_OCI_ENV_CREATE">OTL_ORA_OCI_ENV_CREATE</a>)<br>                           bool threaded_mode=false<br>#endif<br>                          )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // tnsname (TNS alias from TNSNAMES.ORA file) can be specified&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // in order to connect to a remote Oracle 8 server.&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // For local connections, tnsname defaults to 0.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // The function attaches to the database server (local or remote).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // The following "server attachment" attributes that are <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // required by the Oracle XA Library can be also specified:<br>         // server external name, server internal name. Also see <a
 href="#rlogon_xa">rlogon</a>().<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
 name="server_detach"></a>void server_detach(void); // detach from the Oracle 8 server</pre>
<ul>
  <li>Begin / end Oracle 8 session (<b><i>OTL/OCI8/8i/9i/10g/11g</i></b>
only).
These
functions complement the server <a href="#attach_detach">attach/detach</a>
suite of functions, and are used to begin / end an Oracle 8 session.
The
main reason to have separate server attach/detach and session begin/end
groups of function is performance. session_begin() is approximately
50-100
times faster than the normal <a href="#rlogon">rlogon</a>(). These
functions,
along with the <a href="#attach_detach">server_attach</a>() and <a
 href="#server_detach">server_detach</a>()
functions, could be used for implementing a connection management
mechanism
that is several times more efficient [thus, more scalable] than the
traditional
connection pooling.</li>
</ul>
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a name="session_begin"></a>void session_begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (const char* username, // user name, e.g. "scott"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const char* password, // password, e.g. "tiger"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int auto_commit=0, // session <a
 href="#auto_commit">auto-commit</a> mode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const int session_mode=OCI_DEFAULT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // OCI_SYSDBA -- in this mode, the user is authenticated for SYSDBA<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // access.&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // OCI_SYSOPER -- in this mode, the user is authenticated<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // for SYSOPER access.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
 name="session_end"></a>void session_end(void);</pre>
<ul>
  <li>Session reopen (<b><i>OTL/OCI8/8i/9i/10g/11g</i></b> only). If a
session
was
started
via <a href="#session_begin">session_begin</a>() for a given <i>username/password</i>
and then closed via <a href="#session_end">session_end</a>(), another
session
can be started faster (5-10%) for the same username/password via
session_reopen().
This function takes advantage of the fact that the username and
password
attributes of the OCI8/9/10/11 internal connect structure have been
already set
by the previous session_begin() function call. If a session has been
started
via session_reopen(), it can be closed by calling session_end().&nbsp; </li>
  <p>Also, see example <a href="otl3_ex61.htm">61</a></p>
</ul>
<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a name="session_reopen"></a>void session_reopen(const int aauto_commit=0 // session <a
 href="#auto_commit">auto-commit</a> mode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</pre>
<ul>
  <li>Commit transaction. In the otl_connect object, Oracle, ODBC and
DB2-CLI
connections, by default, are set to <i>auto-commit off. </i>This
means
that all transactions need to be commited by explicitly calling the
commit()
function. It is not recommended to use connections that are set to <i>auto-commit
on.</i></li>
  <pre>   <a name="commit"></a>void commit(void);<br><br></pre>
</ul>
<ul>
  <li>Commit transaction asynchronously, same as commit and forget /
commit with no wait. At the moment, avalaible only for Oracle 10g
Release 2 (Oracle 10.2). As soon as the rest of the database vendors
release a similar feature, it will be implemented in OTL.<br>
  </li>
</ul>
<ul>
  <pre>#if defined(<a href="otl3_compile.htm#OTL_ORA10G_R2">OTL_ORA10G_R2</a>)<br>&nbsp;  <a
 name="commit_nowait"></a>void commit_nowait(void);<br>#endif<br></pre>
</ul>
<ul>
  <li><a name="rollback"></a>Roll back transaction</li>
  <pre>&nbsp; void rollback(void);</pre>
  <li>Set otl_connect's <a href="#auto_commit">auto-commit</a> OFF and
ON,
within
one open session/connect. These two functions are for partial backward
compatibility only.</li>
  <pre>&nbsp;&nbsp;<a name="auto_commit_off"></a>void auto_commit_off(void);<br>&nbsp;&nbsp;<a
 name="auto_commit_on"></a>void auto_commit_on(void);</pre>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -