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

📄 otl3_compile.htm

📁 ISO_C++:C++_OTL开发文档
💻 HTM
📖 第 1 页 / 共 5 页
字号:
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">}</span><br
 style="font-family: monospace;">
      <br style="font-family: monospace;">
      <span style="font-family: monospace;">#define <a
 href="#OTL_ORA7_STRING_TO_TIMESTAMP">OTL_ORA7_STRING_TO_TIMESTAMP</a>(s,tm)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">{&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;
sscanf(s,&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"%02d/%02d/%04d %02d:%02d:%02d.%06ld", \</span><br
 style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.month,&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;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.day,&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;&nbsp;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.year,&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;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.hour,&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;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.minute,&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;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.second,&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;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&amp;tm.fraction&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;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\</span><br style="font-family: monospace;">
      <span style="font-family: monospace;">}</span><br
 style="font-family: monospace;">
      </small></small><br>
#define </span><span style="font-weight: normal;"><small><small>OTL_ORA7_STRING_TO_TIMESTAMP
and #define </small></small></span><span style="font-weight: normal;"><small><small>OTL_ORA7_TIMESTAMP_TO_STRING
should be used together as shown in the example above. These #defines
define string-to-timestamp and timestamp-to-string conversion so that
operator&lt;&lt;/&gt;&gt;(otl_datetime&amp;) can be used transparently
with :var&lt;char[XXX]&gt; bind variables. Also, see example <a
 href="otl4_ex473.htm">473</a>.</small></small></span><br>
      <span style="font-weight: normal;"><br>
      </span></td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><a style="font-weight: bold;"
 name="OTL_ORA7_TIMESTAMP_TO_STRING"></a><span
 style="font-weight: bold;">OTL_ORA7_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">TIMESTAMP_TO_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">STRING</span><br>
      </td>
      <td style="vertical-align: top;">This #define should be used
together with #define <span style="font-weight: normal;"><small><small><a
 href="#OTL_ORA7_STRING_TO_TIMESTAMP">OTL_ORA7_STRING_TO_TIMESTAMP</a>.</small></small></span></td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="font-weight: bold;"><a
 name="OTL_ORA_MAP_STRINGS_TO_CHARZ"></a>OTL_ORA_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">MAP_STRINGS_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">TO_CHARZ</span><br>
      </td>
      <td style="vertical-align: top;">OTL normally binds a variable
size string buffer (host variable) with both VARCHAR() and CHAR()
columns. ODBC and DB2 CLI handle variable size vs padded string
comparison semantic correctly for both types of string columns. OCIx do
that a little bit differently. So, when OTL/OCIx is used with CHAR()
columns, if,, say, a WHERE clause has a char[XXX] bind variable, the
actual strings for the WHERE clause need to be padded to the full
length of the CHAR() columns. #define OTL_ORA_MAP_STRINGS_TO_CHARZ
changes the OTL default binding of string host variables. When the
#define is enabled, OTL makes "CHARZ" type string bindings, which
behaves exactly the same as ODBC / DB2 CLI. However, this type of
string binding has a slightly higher runtime overhead. It's up to the
database developer to make the right decision on balancing out
performance vs protability / readability of the source code.<br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top; font-weight: bold;"><a
 name="OTL_ORA_MAX_UNICODE_VARCHAR_SIZE"></a>OTL_ORA_<br>
MAX_UNICODE_<br>
VARCHAR_<br>
SIZE</td>
      <td style="vertical-align: top;">When <a href="#OTL_UNICODE">OTL_UNICODE</a>,
      <a href="#OTL_ORA8I">OTL_ORA8I</a> / <a href="#OTL_ORA9I">OTL_ORA9I</a>
are enabled, and the stream is instantiated with a SELECT statement
that has two (or more) large VARCHAR2(4000), or NVARCHAR2(2000), Oracle
may generate the following error: ORA-01461 (Invalid length...). The
error has to do with the fact that Oracle (8i/9i) treats large
VARCHAR2s / NVARCHAR2s as LONGs, which means that there may be only one
large VARCHAR2 / NVARCHAR2 in a SELECT statement. The only workaround
that Oracle Corporation recommends for Oracle 8i/9i is that the size
of&nbsp; large VARCHAR2s/NVARCHAR2s on a SELECT statement needs to be
limited to 4000 bytes. For PL/SQL block that have large
VARCHAR2/NVARCHAR2 the workaround doesn't apply, that is, there is no
such error, simply because PL/SQL treats large strings differently.
#define OTL_ORA_MAX_UNICODE_VARCHAR_SIZE implements the workaround:<br>
      <br>
      <span style="font-family: monospace;">#define OTL_UNICODE<br>
#define OTL_ORA8I<br>
//#define OTL_ORA9I<br>
int my_max_unicode_varchar_string_size=32000; <br>
&nbsp; // in bytes, the number is not precise, <br>
&nbsp; // the actual maximum may be higher<br>
#define OTL_ORA_MAX_UNICODE_VARCHAR_SIZE (</span><span
 style="font-family: monospace;">my_max_unicode_varchar_string_size)</span><br>
      <span style="font-family: monospace;">#include &lt;otlv4.h&gt;<br>
...<br>
      </span><span style="font-family: monospace;">&nbsp;
my_max_unicode_varchar_string_size=32000; // in bytes<br>
&nbsp; otl_stream o(...); // PL/SQL block that has large
VARCHAR/NVARCHAR strings<br>
...<br>
      </span><span style="font-family: monospace;">&nbsp;
my_max_unicode_varchar_string_size=4000; // in bytes<br>
&nbsp; otl_stream s(...); // SELECT statement that has two or more
large VARCHAR2/NVARCHAR2 strings<br>
      </span><span style="font-family: monospace;">&nbsp;
my_max_unicode_varchar_string_size=32000; // in bytes<br>
...<br>
      <br>
      </span>All of the above is NOT needed under #define OTL_ORA10G /
OTL_ORA10G_R2, or when there is no more than one large
VARCHAR2/NVARCHAR2 in the same SELECT. Sorry for this complicated
stuff: a compliacted bug requires a kludgy fix. The workaround is not
needed for Oracle 10g because Oracle 10g changed the architecture,
compared with Oracle 9i in how large Unicode VARCHAR2 / NVARCHAR2 are
handled inside the Oracle Client / Server.<br>
      <br>
      <span style="font-family: monospace;"></span><br>
      <br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="font-weight: bold;"><a
 name="OTL_ORA_OCI_ENV_CREATE"></a>OTL_ORA_<br>
OCI_ENV_<br>
CREATE</span><br>
      </td>
      <td style="vertical-align: top;">This #define can only be used
when one of the following is defined: <a href="#OTL_ORA8I">OTL_ORA8I</a>,
      <a href="#OTL_ORA9I">OTL_ORA9I</a>, <a href="#OTL_ORA10G">OTL_ORA10G</a>,
      <a href="#OTL_ORA10G_R2">OTL_ORA10G_R2</a>. The #define enables
OCI Environment Handle initialization via OCIEnvCreate() instead of the
older OCIInitialize() + OCIEnvInit() scheme. I don't want to go too
deep into the discussion of what works, and what doesn't work. Those
who want to use OCIEnvCreate(), be my guests.<br>
      <br>
      <br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="font-weight: bold;"><a
 name="OTL_ORA_OCI_ENV_CREATE_MODE"></a>OTL_ORA_<br>
OCI_ENV_<br>
CREATE_<br>
MODE</span><br>
      </td>
      <td style="vertical-align: top;">This define should be used in a
combination with #define <a href="#OTL_ORA_OCI_ENV_CREATE">OTL_ORA_OCI_ENV_CREATE</a>.
When OTL_ORA_OCI_ENV_CREATE_MODE is defined, it overrides the mode
(OCI_DEFAULT/OCI_THREADED) in which OCI environment handles will be
created. For example:<br>
      <br>
      <span style="font-family: monospace;">#define
OTL_ORA_OCI_ENV_CREATE </span><br style="font-family: monospace;">
      <span style="font-family: monospace;">#define
OTL_ORA_OCI_ENV_CREATE_MODE OCI_THREADED</span><br
 style="font-family: monospace;">
      <br>
The problem that this #define is trying to address is that the
"default/threaded" mode was passed into otl_connect::otl_initialize()
once in the whole program, instead of having to pass the same parameter
into all calls to otl_connect::<a
 href="otl3_connect_class.htm#rlogon_xa">rlogon</a>() or <a
 href="otl3_connect_class.htm#server_attach">server_attach(</a>). When
this #define is enabled, it overrides everything else, so that the
custom code wouldn't have to be changed. <br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="font-weight: bold;"><a
 name="OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS"></a>OTL_STREAM_<br>
NO_PRIVATE_<br>
BOOL_<br>
OPERATORS</span><br>
      </td>
      <td style="vertical-align: top;">By default, OTL makes
otl_stream::operator&gt;&gt;(bool&amp;) and operator&lt;&lt;(const
bool) private because they are not implemented, and in some cases it is
very confusing when the C++ compiler use a different operator, say,
instead of operator&gt;&gt;(bool&amp;) . It makes it harder to track
down bugs in the code at runtime.&nbsp; By making the operators
private,&nbsp; the runtime bugs of that sort become more obvious at
compile time. However, there may be legitimate use cases when there is
a need to overload operator&gt;&gt;(bool&amp;) and
operator&lt;&lt;(const bool). This #define, when enabled, prevents OTL
from declaring private operator&gt;&gt;(bool&amp;) and
operator&lt;&lt;(const bool) in the otl_stream class.<br>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="font-weight: bold;"><a
 name="OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS"></a>OTL_STREAM_<br>
NO_PRIVATE_<br>
UNSIGNED_<br>
LONG_<br>
OPERATORS</span><br>
      </td>
      <td style="vertical-align: top;">By default, OTL makes
otl_stream::operator&gt;&gt;(unsigned long&amp;) and
operator&lt;&lt;(const unsigned long) private because they are not
implemented,
and in some cases it is very confusing when the C++ compiler use a
different operator, say, instead of operator&gt;&gt;(unsigned
long&amp;). It
makes it harder to track down bugs in the code at runtime.&nbsp; By
making
the operators private,&nbsp; the runtime bugs of that sort become more
obvious at compile time. However, there may be legitimate use cases
when there is a need to overload operator&gt;&gt;(unsigned long&amp;)
and
operator&lt;&lt;(const unsigned long). This #define, when enabled,
prevents OTL
from declaring private operator&gt;&gt;(unsigned long&amp;) and
operator&lt;&lt;(const unsigned long) in the otl_stream class.</td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><span style="font-weight: bold;"><a
 name="OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT"></a>OTL_STRICT_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">NUMERIC_TYPE_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">CHECK_</span><br
 style="font-weight: bold;">
      <span style="font-weight: bold;">ON_SELECT</span><br>
      </td>
      <td style="vertical-align: top;">By default on an SELECT
statement, or a stored procedure that returns an implcit result set
(ODBC, DB2 CLI) / a reference cursor (PL/SQL), OTL

⌨️ 快捷键说明

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