📄 otl3_compile.htm
字号:
can be used to check for NULL. This default vaue is more of a
convenience
than necessity. </td>
</tr>
<tr>
<td style="vertical-align: top;"><a
name="OTL_DESTRUCTORS_DO_NOT_THROW"></a><span
style="font-weight: bold;">OTL_DESTRUCTORS_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">DO_NOT_THROW</span><br>
</td>
<td style="vertical-align: top;">Top C++ experts say that
"throwing destructors" are bad. OTL throws execptions from destructors
by default in order to communicate database errors via otl_exceptions.
OTL also makes the maximum effort (see #define <a
href="#OTL_UNCAUGHT_EXCEPTION_ON">OTL_UNCAUGHT_EXCEPTION_ON</a> for
more detail) to detect the stack unwinding situation and not to throw
exceptions from destructors in that case, because that would result in
an immediate program abort. #define OTL_DESTRUCTORS_DO_NOT_THROW
enables try/catch blocks to prevent OTL destructors from throwing
exceptions. See <a
href="http://kolpackov.net/projects/c++/eh/dtor-1.xhtml">this</a> for
more detail on the topic. It's strongly recommended, if you enable this
#define, to make sure that every single instance of otl_connect,
otl_stream, otl_lob_stream releases its underlying resources when t
goes
out of scope. In the worst case, information about a database error may
be lost.<br>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><a name="OTL_ENABLE_MSSQL_MARS"></a><span
style="font-weight: bold;">OTL_ENABLE_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">MSSQL_MARS</span><br>
</td>
<td style="vertical-align: top;">MS SQL SQL 2005 and 2008 support
the Multiple Active Result Sets (MARS), which is not enabled by
default. In order for MARS to be enabled, an ODBC function call needs
to be made. This #define enables the ODBC function call.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><a
name="OTL_EXCEPTION_IS_DERIVED_FROM_STD_EXCEPTION"></a><span
style="font-weight: bold;">OTL_EXCEPTION_<br>
IS_DERIVED_FROM_<br>
STD_EXCEPTION</span><br>
</td>
<td style="vertical-align: top;">This #define is a shortcut for
the following:<br>
<br>
<span style="font-family: monospace;">#define <a
href="#OTL_EXCEPTION_DERIVED_FROM">OTL_EXCEPTION_DERIVED_FROM</a>
std::exception</span><br style="font-family: monospace;">
<span style="font-family: monospace;">#define <a
href="#OTL_EXCEPTION_HAS_MEMBERS">OTL_EXCEPTION_HAS_MEMBERS</a>
\</span><br style="font-family: monospace;">
<span style="font-family: monospace;"> virtual
const char* what()
const
\</span><br style="font-family: monospace;">
<span style="font-family: monospace;">
{
\</span><br style="font-family: monospace;">
<span style="font-family: monospace;">
return reinterpret_cast<const
char*>(msg); \</span><br
style="font-family: monospace;">
<span style="font-family: monospace;"> } <br>
</span><br style="font-family: monospace;">
It means that <a href="otl3_exception_class.htm">otl_exception</a> is
derived from std::exception.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><font size="-1"><a
name="OTL_EXCEPTION_DERIVED_FROM"></a><b>OTL_EXCEPTION<br>
_DERIVED_FROM</b> </font></td>
<td style="vertical-align: top;">This #define
allows the <a href="otl3_exception_class.htm">otl_exception</a>
class to be included into already exsisting hierarchy of exception
classes.
The #define should specify a name of already existing class, which is
used
as part of the exception class hierarchy. The STL exception class
hiararchy
is a good example. otl_exception can be derived from one of the classes
in the hierarchy, so that a catch block, that catches exception of the
base class, will be able to catch exceptions of the otl_exception
class.
In the OTL header file, in case if this #define is defined, the class,
defined in the #define, will be specified as a base class for the
otl_exception
class. </td>
</tr>
<tr>
<td style="vertical-align: top;"><span style="font-weight: bold;"><a
name="OTL_EXCEPTION_ENABLE_ERROR_OFFSET"></a>OTL_EXCEPTION_<br>
ENABLE_<br>
ERROR_<br>
OFFSET</span></td>
<td style="vertical-align: top;">This #define enables the so
called SQL Statement Parse Error Offset, and it is available for
OTL/OCIx only. When an otl_exception gets thrown, and it has
otl_exception::stm_text field populated, the parse error offset will
point to the actual position of the SQL error.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><font size="-1"><a
name="OTL_EXCEPTION_HAS_MEMBERS"></a><b>OTL_EXCEPTION<br>
_HAS_MEMBERS</b></font></td>
<td style="vertical-align: top;">This #define
allows the user to
define new member functions or data
members
in the <a href="otl3_exception_class.htm">otl_exception</a>
class. The
OTL header file checks out whether this #define is defined, and then
the
body of the #define gets included textually into the body of the
otl_exception
class. This simple technique allows the otl_exception class to have new
members. This #define can be used in a combination with #define <a
href="otl3_compile.htm#OTL_EXCEPTION_DERIVED_FROM">OTL_EXCEPTION_DERIVED_FROM</a>.
</td>
</tr>
<tr>
<td style="vertical-align: top;"><font size="-1"><a
name="OTL_EXPLICIT_NAMESPACES"></a><b>OTL_EXPLICIT<br>
_NAMESPACES</b> <br>
</font></td>
<td style="vertical-align: top;">(for
turning on namespaces) </td>
</tr>
<tr>
<td style="vertical-align: top;"><span style="font-weight: bold;"><a
name="OTL_EXCEPTION_STM_TEXT_SIZE"></a>OTL_EXCEPTION_<br>
STM_TEXT_<br>
SIZE</span><br>
</td>
<td style="vertical-align: top;">This #define specifies a new
size for the <a href="otl3_exception_class.htm">otl_exception</a>::<a
href="otl3_exception_class.htm#stm_text">stm_text</a> buffer. By
default, it's 2048 bytes, that is, the actual otl_exception will
contain only 2047 first bytes of the SQL statement, associated with the
exception. If more bytes of the SQL statement text is needed, the
#define can come handy.This #define can be used in a combination with
#define <a href="#OTL_EXCEPTION_ENABLE_ERROR_OFFSET">OTL_EXCEPTION_ENABLE_ERROR_OFFSET</a>,
for example:<br>
<br>
<span style="font-family: monospace;">#define
OTL_EXCEPTION_ENABLE_ERROR_OFFSET<br>
#define OTL_EXCEPTION_STM_TEXT_SIZE 32767<br>
</span><br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><font size="-1"><a
name="OTL_EXTENDED_EXCEPTION"></a><b>OTL_EXTENDED<br>
_EXCEPTION</b> </font></td>
<td style="vertical-align: top;">(for
enabling the otl_exception's <a
href="otl3_exception_class.htm#EXTENDED">extended
fields</a> for OTL/ODBC and OTL/DB2-CLI). This is for fixing problem <a
href="otl3_prob.htm#prob47">47.</a> </td>
</tr>
<tr>
<td style="vertical-align: top;"><a
name="OTL_ODBC_LOGOFF_FREES_HANDLES"></a><span
style="font-weight: bold;">OTL_ODBC_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">LOGOFF_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">FREES_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">HANDLES</span><br>
</td>
<td style="vertical-align: top;">Some ODBC drivers can't reuse
underlying ODBC connect related resources. In order for OTL to fully
recover from a database failure, the resources need to be released and
new resources need to be allocated for otl_connect objects to work.
Some versions of the Oracle ODBC driver for Oracle show that type
behavior. This #define forces otl_connect::logoff() to the ODBC connect
resources so that the next call to otl_connect::rlogon() would allocate
the resources again.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><span style="font-weight: bold;"><a
name="OTL_ODBC_STRING_TO_TIMESTAMP"></a>OTL_ODBC_<br>
STRING_TO_<br>
TIMESTAMP</span><br>
</td>
<td style="vertical-align: top;">This #define defines conversion
from the string/varchar format to the timestamp format (<a
href="otl3_stream_class.htm#otl_datetime">otl_datetime</a>), for
example, PostgreSQL's timestamps with time zone, or MS SQL Server
2008's datetimeoffset(7):<br>
<br>
for PostgreSQL:<br>
<pre>#define OTL_ODBC_STRING_TO_TIMESTAMP(str,tm) \<br>{ \<br> sscanf(str, \<br> "%04d-%02d-%02d %02d:%02d:%02d.%06ld%hd", \<br> &tm.year, \<br> &tm.month, \<br> &tm.day, \<br> &tm.hour, \<br> &tm.minute, \<br> &tm.second, \<br> &tm.fraction, \<br> &tm.tz_hour); \<br>}<br><br></pre>
for MS SQL 2008:<br>
<pre>#define OTL_ODBC_STRING_TO_TIMESTAMP(str,tm) \<br>{ \<br> sscanf(str, \<br> "%04d-%02d-%02d %02d:%02d:%02d.%07ld %hd:%hd", \<br> &tm.year, \<br> &tm.month, \<br> &tm.day, \<br> &tm.hour, \<br> &tm.minute, \<br> &tm.second, \<br> &tm.fraction, \<br> &tm.tz_hour, \<br> &tm.tz_minute); \<br>}</pre>
<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><span style="font-weight: bold;"><a
name="OTL_ODBC_TIMESTAMP_TO_STRING"></a>OTL_ODBC_<br>
TIMESTAMP_<br>
TO_STRING</span><br>
</td>
<td style="vertical-align: top;">This #define defines conversion
the timestamp format (<a
href="file:///D%7C/oscl/vc/doc/otl4/otl3_stream_class.htm#otl_datetime">otl_datetime</a>)
to the string/varchar format, for example, PostgreSQL's timestamp with
time zone, or MS SQL Server 2008's datetimeoffset(7):<br>
<br>
for PostgreSQL:<br>
<pre>#define OTL_ODBC_TIMESTAMP_TO_STRING(tm,str) \<br>{ \<br> sprintf(str, \<br> "%04d-%02d-%02d %02d:%02d:%02d.%06ld %+hd", \<br> tm.year, \<br> tm.month, \<br> tm.day, \<br> tm.hour, \<br> tm.minute, \<br> tm.second, \<br> tm.fraction, \<br> tm.tz_hour); \<br>}<br></pre>
for MS SQL 2008:<br>
<pre>#define OTL_ODBC_TIMESTAMP_TO_STRING(tm,str) \<br>{ \<br> sprintf(str, \<br> "%04d-%02d-%02d %02d:%02d:%02d.%07ld %+hd:%hd", \<br> tm.year, \<br> tm.month, \<br> tm.day, \<br> tm.hour, \<br> tm.minute, \<br> tm.second, \<br> tm.fraction, \<br> tm.tz_hour, \<br> tm.tz_minute); \<br>}<br></pre>
</td>
</tr>
<tr>
<td style="vertical-align: top; font-weight: bold;"><a
name="OTL_ODBC_TIME_ZONE"></a>OTL_ODBC_<br>
TIME_ZONE<br>
</td>
<td style="vertical-align: top;">This #define enables tz_hour,
and tz_minute fields in the <a
href="otl3_stream_class.htm#otl_datetime">otl_datetime</a> class. ODBC
doesn't support the time zone components yet, so this #define needs to
be used with #define <a href="#OTL_ODBC_STRING_TO_TIMESTAMP">OTL_ODBC_STRING_TO_TIMESTAMP</a>
and #define <a href="#OTL_ODBC_TIMESTAMP_TO_STRING">OTL_ODBC_TIMESTAMP_TO_STRING</a>.<br>
</td>
</tr>
<tr>
<td style="vertical-align: top;"><span style="font-weight: bold;"><a
name="OTL_FREETDS_ODBC_WORKAROUNDS"></a>OTL_FREETDS_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">ODBC_</span><br
style="font-weight: bold;">
<span style="font-weight: bold;">WORKAROUNDS</span><br>
</td>
<td style="vertical-align: top;">FreeTDS/ODBC doesn't seem to
implement the database session's "auto-commit off" mode, so
otl_connect's <a href="otl3_connect_class.htm#rlogon">auto_commit</a>
has no effect. In order to work around this deficiency, this #define
should be used. When the #define is enabled, OTL executes "begin
transaction" statement before each transaction. otl_connect::commit()
or otl_connect::rollback() can be used to commit or roll back the
transaction. When FreeTDS/ODBC implements the database session's
"auto-commit off" mode, the #define could be safely removed, because
the otl_connect's auto-commit parameter would take effect on the
database sessions. For the time being, this #define is recommended for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -