📄 otl3_faq.htm
字号:
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Sergei Kuchin">
<meta name="GENERATOR"
content="Mozilla/4.77 [en] (Win95; U) [Netscape]">
<meta name="KeyWords"
content="OTL, Oracle, ODBC, DB2, CLI, database API, C++, Template Library">
<title>Oracle, Odbc and DB2-CLI Template Library, Version 4.0,
Frequently Asked Questions</title>
</head>
<body>
<ul>
<center>
<h1>Oracle, Odbc and DB2-CLI Template Library, Version 4.0</h1>
</center>
<center>
<h1>Frequently Asked Questions</h1>
</center>
</ul>
Please, send your questions and comments to <a
href="mailto:skuchin@aceweb.com">skuchin@aceweb.com</a>,
<a href="mailto:skuchin@gmail.com">skuchin@gmail.com</a><br>
<i><font size="+1"><br>
</font></i><i><font size="+1">Q. OTL: how does OTL handle NULLs?</font></i>
<ul>
<li>Call otl_stream::<a href="otl3_stream_class.htm#is_null">is_null</a>()
to check whether the value that was just read from the stream is NULL
or
not.<br>
</li>
<br>
<li>Use template class <a href="otl3_value.htm">otl_value</a><T>.<br>
<br>
</li>
<li>If there is a need to set the output variable to a value when
NULL is fetched (by default, OTL does not set the output byffer to any
value in the case of NULL), the following #defines could be enabled:<br>
<br>
</li>
<ul>
<li> <a href="otl3_compile.htm#OTL_DEFAULT_NUMERIC_NULL_TO_VAL">OTL_DEFAULT_NUMERIC_NULL_TO_VAL</a></li>
<li> <a href="otl3_compile.htm#OTL_DEFAULT_DATETIME_NULL_TO_VAL">OTL_DEFAULT_DATETIME_NULL_TO_VAL</a></li>
<li> <a href="otl3_compile.htm#OTL_DEFAULT_STRING_NULL_TO_VAL">OTL_DEFAULT_STRING_NULL_TO_VAL</a></li>
<li> <a href="otl3_compile.htm#OTL_DEFAULT_CHAR_NULL_TO_VAL">OTL_DEFAULT_CHAR_NULL_TO_VAL</a></li>
<li><a
href="otl3_compile.htm#OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL">OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL</a></li>
</ul>
</ul>
<br>
<i><font size="+1"><a name="Nested_Quesry"></a>Q. OTL: why nested
queries with bind variables do
not work in MS SQL Server?</font></i>
<br>
<br>
Try to add otl_implicit_select right after the otl_connect parameter,
when you are opening the nested SELECT:<br>
<pre wrap=""> otl_stream s(1,<br> "select dt from "<br> " (select "<br> " dateadd(day, <span
style="color: rgb(0, 153, 0);">:v<int></span>, getdate() "<br> " )dt ) xt ",<br> db, // connect object<br> <span
style="font-style: italic;">otl_implicit_select</span><br> );<br><br></pre>
Problem is that SQLPrepare() doesn't return any SELECT output column
descriptors (OTL exception: Column: 0<UNKNOWN>), and it looks
like the nested SELECT gets converted into a temporary stored
procedure, which means you have to specify that it is a stored proc
that returns an implicit result set. I don't know why the database
server does it, probably as an optimization technique.<br>
<br>
<i><font size="+1"><a name="NO_DSN"></a>Q. OTL: How do I connect to my
database without
creating an ODBC DSN?</font></i>
<br>
<br>
Take a look this <a href="http://www.connectionstrings.com/">Web site</a>.<br>
<br>
<i><font size="+1">Q. OTL: is it thread safe?</font></i>
<p></p>
<p>OTL does not set any mutex locks or critical sections. In case if
each
thread has its own otl_connect object, there is no need for mutex
locks.
In case of sharable connections, it is the devloper's responsibility to
wrap up OTL calls with mutexes. In general, database APIs do not
guarantee
thread safety. otl_connect::<a
href="otl3_connect_class.htm#otl_initialize">otl_initialize</a>
passes a flag to the underlying database API only to let the API know
that
the progam is running in a multi-threaded mode.
</p>
<p><i><font size="+1">Q. OTL: does it work with SQLite?</font></i>
</p>
<p>Yes, it does. OTL/ODBC works with SQLite. See the following <a
href="otl4_sqlite_examples.htm">examples</a> for detail.<br>
</p>
<p><i><font size="+1">Q. OTL: does it support Oracle 10g?</font></i>
</p>
<p>The answer is Yes. Use #define
<a href="otl3_compile.htm#OTL_ORA10G">OTL_ORA10G</a>, <a
href="otl3_compile.htm#OTL_ORA10G_R2">OTL_ORA10G</a><a
href="otl3_compile.htm#OTL_ORA10G_R2">_R2</a> </p>
<p>
</p>
<p><i><font size="+1">Q. OTL: does it work with SAP DB?</font></i>
</p>
<p>Yes, it does. OTL/ODBC works with SAP DB. Fore more detail, see OTL <a
href="otl4_sap_db_examples.htm">examples</a> for SAP DB.
</p>
<p><i><font size="+1">Q. OTL: does it support CLOBs/BLOBs in PL/SQL?</font></i>
</p>
<p>The answer is: it depends. You need to keep in mind that "CLOB/BLOB"
as a PL/SQL datatype is a <i>locator</i> of a large object, not a
value.
That is, the object itself needs to be created first, its locator needs
to be retrieved from the database into C++, and only then the locator
can
be passed into PL/SQL. Also, see code example <a href="otl4_ex378.htm">378</a>.<br>
</p>
<p><i><font size="+1">Q. OTL: does it support Unicode?</font></i>
</p>
<p>The answer is Yes. See OTL examples and the manual. <br>
</p>
<p><i><font size="+1">Q. OTL: does it support Oracle 9i?</font></i>
</p>
<p>The answer is Yes. Starting with version 4.0.0, OTL introduces
#define
<a href="otl3_compile.htm#OTLORA9I">OTL_ORA9I</a>
that is dedicated to Oracle 9i. In OTL 4.0.0 itself, it's not much more
than a synonym for OTL_ORA8I, but in subsequent releases, when OTL
starts
using OCI9 specific features, only OTL_ORA9I should be used. See "<a
href="otl3_whatn.htm#NEW_OTL400">what's
new in OTL 4</a>" for more detail.
</p>
<p><i><font size="+1">Q. OTL: can it work with Interbase 6.x?</font></i>
</p>
<p>The answer is Yes. Starting with version 4.0.0, OTL supports an Open
Source ODBC driver for Interbase. See "<a
href="otl3_whatn.htm#NEW_OTL400">what's
new in OTL 4</a>" for more detail.
</p>
<p><i><font size="+1">Q. OTL: can it work with PostgreSQL 7.x?</font></i>
</p>
<p>The answer is Yes. Starting with version 4.0.0, OTL supports
PostgreSQL
via ODBC. See "<a href="otl3_whatn.htm#NEW_OTL400">what's new in OTL 4</a>"
for more detail.
<br>
</p>
<p><i><font size="+1">Q. OTL: can it work with DB2, Call Level
Interface
(CLI)?</font></i>
</p>
<p>The answer is Yes. Starting with version 3.2.7, there is a new
flavor
of OTL: OTL/DB2-CLI. OTL/DB2-CLI uses DB2's native database API: the <i>Call
Level Interface.</i> DB2-CLI is 99.5% compatible with the ODBC 3.x
specification,
plus extensions. The OTL header file #includes CLI's native header
files
and can be used with DB2-CLI's native object libraries in Windows or
Unix
(primarily AIX) platforms.
<br>
</p>
<p><i><font size="+1"><a name="MYSQL"></a>Q. OTL/ODBC: can it work with
MyODBC/MySQL?</font></i>
</p>
<p>The answer is Yes. Starting with OTL 3.2.4, OTL/ODBC is
compatible
with MyODBC. For
more detail on MyODBC see <a href="otl3_examples.htm#MYODBC">MyODBC
for
MySQL</a>. #define <a href="otl3_compile.htm#OTL_ODBC_MYSQL">OTL_ODBC_MYSQL</a>
should be used with the default MySQL table type, because OTL turns off
transactional ODBC function calls in that case. When InnoDB type tables
are used with MyODBC 3.5, #define <a href="otl3_compile.htm#OTL_ODBC">OTL_ODBC</a>
should be used.<br>
</p>
<p><i><font size="+1">Q. OTL/OCI8 and XA-connectivity: can they work
together?</font></i>
</p>
<p>The answer is Yes. When an XA type connection is established,
xaoEnv()
and xaoSvcCtx() functions need to be invoked in order to get OCI8
compatible
environment and service context handles. After that, otl_connect::<a
href="otl3_connect_class.htm#attach8">rlogon</a>()
can be called to create an OTL connection from the handles. It is the
same
rlogon() that is used with Pro*C 8.x. How to use this type of rlogon()
function, see example <a href="otl3_ex59.htm">59</a> for more detail.
</p>
<p><i><font size="+1">Q. Are C++ strings (std::string) supported, and
how
is OTL integrated with the Standard Template Library (STL)?</font></i>
</p>
<p>OTL 3.2.0 and higher support <i>std::strings</i> (see examples
<a href="otl3_ex72.htm">72</a>,
<a href="otl3_ex73.htm">73</a>,
<a href="otl3_ex74.htm">74</a>).
Also, OTL supports STL-compliant stream iterators: <a
href="otl3_input_iterator.htm">otl_input_iterator</a>,
<a href="otl3_output_iterator.htm">otl_output_iterator</a>.
</p>
<p><i><font size="+1">Q. What major C++ compilers are supported, anyway?</font></i>
</p>
<ul>
<li>Sun C++ Workshop 5.x/6.0, Forte C++ (Sun C++ WS 6.1 and higher)</li>
<li>GNU C++ 2.9x.x, 3.0.x, 3.1.x, 3.2.x., 3.3.x, 3.4.x, 4.0.x<br>
</li>
<li>VC++ 6.0, VC++ 7.1, VC++ 8.0<br>
</li>
<li>HP ANSI C++ (aCC) 1.x</li>
<li>AIX, xlC 4.x and higher</li>
<li>C++ in OSF Alfa Unix and Oracle 7.3.4</li>
<li>Borland C++ 5.x</li>
<li>KAI C++ 3.x and higher (multi-platform)</li>
<li>Intel C++ 7.0, 8.0, 9.x (Windows, Linux)</li>
</ul>
In order to complete the list, you are welcome to send me an email with
the name of your C++ compiler, if it's not already in the list.
<br>
<p><i><font size="+1">Q. Is there a way to read / write large BLOBs
without
having to allocate large buffers in memory?</font></i>
</p>
<p>OTL 3.1.4 supports <a href="otl3_lob_stream.htm">stream mode</a>
for
Oracle 8 CLOBs/BLOBs. Fore more detail, see examples <a
href="otl3_ex56.htm">56</a>,
<a href="otl3_ex57.htm">57.</a>
</p>
<p><i><font size="+1">Q. Is there a way to call a stored procedure
which
takes PL/SQL tables as arguments ?</font></i>
</p>
<p>OTL 3.1 supports PL/SQL table via <a
href="otl3_bind_variables.htm#pl_tab">otl_streams</a>
and <a href="otl3_pl_tab.htm">special template data containers</a>.Fore
more detail, see examples <a href="otl3_ex49.htm">49</a>, <a
href="otl3_ex50.htm">50</a>,
<a href="otl3_ex51.htm">51</a>,
<a href="otl3_ex52.htm">52</a>.
</p>
<p><i><font size="+1">Q. Will you stick with email delivery of your
code,
or do you intend to put it on your website later ?</font></i>
</p>
<p>From now on, the OTL header file is available for <a
href="otlv4_h.zip">download</a>.
</p>
<p><i><font size="+1">Q. What is different in behavior of Large Objects
(LOBs)
compared to other datatypes as far as NULLs are concerned?</font></i>
</p>
<p>For more detail, see "<a href="otl3_long_string.htm#LOB_and_NULL">Large
Objects and NULLs</a>."
</p>
<p><i><font size="+1">Q. How to read/write date&time informarion
from/to
the <a href="otl3_stream_class.htm">otl_stream</a>?</font></i>
</p>
<p>The answer is: use the <a href="otl3_stream_class.htm#otl_datetime">otl_datetime</a>
data container, which was introduced in OTL 3.1.26. For more detail, se
examples <a href="otl3_ex38.htm">38</a>, <a href="otl3_ex39.htm">39</a>,
<a href="otl3_ex40.htm">40</a>.
<br>
Bottom line: Oracle DATE, or, say, MS SQL Server DATETIME, can be
read/written
with the use of otl_datetime variables.
</p>
<p><i><font size="+1">Q. How to get the <b>rows processed count</b>
after
the SQL statement is finished?</font></i>
</p>
<p>The <a href="otl3_const_sql.htm">direct_exec</a>() function returns
a long int value, which, if it is >= 0, it retunrs the rows
processed count
of the constant SQL statement.Also, otl_stream::<a
href="otl3_stream_class.htm#get_rpc">get_rpc</a>()
returns a long int value, which is the rows processed count. The rows
processed
count is defined for INSERT, UPDATE, and DELETE statements. For any
other
SQL statement, PL/SQL block, or a stored procedure call, the count is
always
0.
<br>
</p>
<p></p>
<hr width="100%">
<ul>
<center><a href="home.htm">Go Home</a></center>
<p>Copyright © 1996, 2008, Sergei Kuchin, email: <a
href="mailto:skuchin@aceweb.com">skuchin@aceweb.com</a>, <a
href="mailto:skuchin@gmail.com">skuchin@gmail.com
<script language="JavaScript"><!-- hide from old browsers
var modDate = new Date(document.lastModified)
document.write("<i> Last Updated:</i> " + (modDate.getMonth()+1) + "/" +
modDate.getDate() + "/" + "0"+(modDate.getYear())%100+".");
//-->
</script></a>.
</p>
<p><i>Permission to use, copy, modify and redistribute this document
for
any purpose is hereby granted without fee, provided that the above
copyright
notice appear in all copies.</i></p>
</ul>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -