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

📄 otl3_pl_tab.htm

📁 otl是c++数据库封装好的一个数据库接口
💻 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>OTL template, dynamic, and STL vector based containers for PL/SQL tables (OCIx)</title>
</head>
<body>

<center>
<h1>
OTL 4.0, OTL template, dynamic, and STL vector based containers for PL/SQL
tables (OCIx)</h1></center>

<h1>
OTL template, dynamic, and STL vector based containers for PL/SQL tables
(OCIx)</h1>
In OTL 3.x, a set of new template, dynamically allocated, and STL vector
based data containers were introduced to support PL/SQL tables as parameters
via otl_streams:
<p><b><i>Numeric PL/SQL tables</i></b>
<ul><b>Template containers</b></ul>

<pre>&nbsp;&nbsp; template class otl_int_tab&lt;int max_tab_size>;
&nbsp;&nbsp; template class otl_double_tab&lt;int max_tab_size>;
&nbsp;&nbsp; template class otl_float_tab&lt;int max_tab_size>;
&nbsp;&nbsp; template class otl_unsgined_tab&lt;int max_tab_size>;
&nbsp;&nbsp; template class otl_short_tab&lt;int max_tab_size>;
&nbsp;&nbsp; template class otl_long_int_tab&lt;int max_tab_size>;</pre>

<ul><b>Dynamically allocated containers</b></ul>

<pre>&nbsp;&nbsp; class otl_dynamic_int_tab(int max_tab_size=1);
&nbsp;&nbsp; class otl_dynamic_double_tab(int max_tab_size=1);
&nbsp;&nbsp; class otl_dynamic_float_tab(int max_tab_size=1);
&nbsp;&nbsp; class otl_dynamic_unsgined_tab(int max_tab_size=1);
&nbsp;&nbsp; class otl_dynamic_short_tab(int max_tab_size=1);
&nbsp;&nbsp; class otl_dynamic_long_int_tab(int max_tab_size=1);</pre>

<ul><b>STL vector based containers</b></ul>

<pre>&nbsp;&nbsp; class otl_int_vec;
&nbsp;&nbsp; class otl_double_vec;
&nbsp;&nbsp; class otl_float_vec;
&nbsp;&nbsp; class otl_unsgined_vec;
&nbsp;&nbsp; class otl_short_vec;
&nbsp;&nbsp; class otl_long_int_vec;</pre>
<b><i><a href="otl3_stream_class.htm#otl_datetime">Date &amp; time</a>
PL/SQL tables</i></b>
<ul><b>Template container</b></ul>

<pre>&nbsp;&nbsp;&nbsp; template class otl_datetime_tab&lt;int max_tab_size>;</pre>

<ul><b>Dynamically allocated container</b></ul>

<pre>&nbsp;&nbsp;&nbsp; class otl_dynamic_datetime_tab(int max_tab_size=1);</pre>

<ul><b>STL vector based container</b></ul>

<pre>&nbsp;&nbsp;&nbsp; class otl_datetime_vec;</pre>
<b><i>C-string (null terminated) PL/SQL tables</i></b>
<ul><b>Template container</b></ul>

<pre>&nbsp;&nbsp;&nbsp; template class otl_cstr_tab&lt;int max_tab_size, int max_str_size>;</pre>

<ul><b>Dynamically allocated container</b></ul>

<pre>&nbsp;&nbsp;&nbsp; template class otl_dynamic_cstr_tab&lt;int max_str_size>(int max_tab_size=1);</pre>
<b><i>STL string (std::string), STL vector based PL/SQL tables</i></b>
<pre>&nbsp; class otl_string_vec;</pre>

<p><br><b>max_tab_size</b> defines the PL/SQL table maximum size.
<br><b>max_str_size </b>defines the string maximum size, in case of the
otl_cstr_tab template class and the otl_dynamic_cstr_tab class.
<p>The difference between the template and dynamic containers is that the
<i>max_tab_size
</i>is a template parameter in the template containers and a constructor
parameter in the dynamic containers. Therefore, the template containers
define the table size statically, at compile time, and the dynamic containers
define the table size dynamically, at runtime.
<p>STL vector based data containers do not have any restrictions on the
container size, nor they have any initial size requirements. Everything
is controlled by the STL vector memory allocator.
<br>&nbsp;
<p>Each PL/SQL table template, dynamic, and STL vector based class has
the following data member:
<p><i>Numerics, Date &amp; times:</i>
<pre>&nbsp;&nbsp; T <b>v</b>[max_tab_size]; // template container

&nbsp;&nbsp; T* <b>v</b>=new T[max_tab_size]; // dynamic container

&nbsp;&nbsp; std::vector&lt;T> <b>v</b>; // vector based container</pre>
<i>Strings</i>
<pre>&nbsp;&nbsp; typedef unsigned char T[max_str_size]; // both template and dynamic containers

&nbsp;&nbsp; T <b>v</b>[max_tab_size]; // template container

&nbsp;&nbsp; T* <b>v</b>=new T[max_tab_size]; // dynamic container</pre>

<pre>&nbsp;&nbsp; std::vector&lt;std::string> <b>v</b>; // string vector container


and member functions:&nbsp;
</pre>

<table BORDER=2 >
<tr>
<td>int <b>is_null</b>(int ndx=0)</td>

<td>Check if the <b>N</b>th element of the PL/SQL table is NULL</td>
</tr>

<tr>
<td>void <b>set_null</b>(ind ndx=0)</td>

<td>Set if the <b>N</b>th element of the PL/SQL table to NULL</td>
</tr>

<tr>
<td>void <b>set_non_null</b>(int ndx=0)</td>

<td>If the <b>N</b>th element of the PL/SQL table was set to a value, then
this functions needs to be called to set the null flag to NOT NULL</td>
</tr>

<tr>
<td>int <b>len</b>()</td>

<td>This function returns the dynamic length of the PL/SQL table . It is
needed if PL/SQL tables are OUT or IN OUT parameters in stored procedures.</td>
</tr>

<tr>
<td>void <b>set_len</b>(int new_len)</td>

<td>Set the dynamic length of the PL/SQL table. It is needed if PL/SQL
tables are IN parameters in stored procedures. <i>Important: this function
needs to be called first, to set the size of the vector based container,
and only after that to assign values to the elements of the container.</i></td>
</tr>
</table>

<p>Also, 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> (template containers), examples <a href="otl3_ex68.htm">68</a>,
<a href="otl3_ex69.htm">69</a>,
<a href="otl3_ex70.htm">70</a>, <a href="otl3_ex71.htm">71</a>
(dynamic containers), and examples <a href="otl3_ex85.htm">85</a>, <a href="otl3_ex86.htm">86</a>,
<a href="otl3_ex87.htm">87</a>,
<a href="otl3_ex88.htm">88</a> (vector based containers)
<p>When #define <a href="otl3_compile.htm#OTL_UNICODE">OTL_UNICODE</a>
is enabled, character/string PL/SQL table containers will be populated
with NULL terminated Unicode character strings, even though the string
buffer size was specified in bytes. Therefore, the size of buffer needs
to be calculated accordingly: 2 bytes per Unicode character + 2 bytes for
a possible surrogate character that can be added for each Unicode character
+ 2-byte NULL terminator and the end of the string. In order to access
the Unicode character array/string the char[] buffer needs to be type cast
to "unsigned short*". See code samples for more detail.
<center>
<p>
<hr WIDTH="100%">
<p><a href="otl3_long_string.htm">Prev</a> <a href="otl3_lob_stream.htm">Next</a><a href="otl3.htm">Contents</a><a href="home.htm">Go
Home</a></center>

<p>Copyright &copy; 1996, 2008, Sergei Kuchin, email: <a href="mailto:skuchin@aceweb.com">skuchin@aceweb.com</a>,
<i>Last
Updated:</i>
<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>
</body>
</html>

⌨️ 快捷键说明

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