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

📄 otl4_ex238.htm

📁 otl是c++数据库封装好的一个数据库接口
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE doctype 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 4.0, Example 238</title>
</head>
<body>
<center>
<h1> OTL 4.0, Example 238 (OTL/DB2-CLI, accessing the system data
dictionary via DB2 CLI functions, DB2)</h1>
</center>
This example demonstrates how to access the database system data
dictionary via DB2 CLI functions, OTL/DB2-CLI, DB2.
<h2> Source Code</h2>
<pre>#include &lt;iostream&gt;<br>#include &lt;stdio.h&gt;<br>using namespace std;<br><br>#define OTL_DB2_CLI // Compile OTL 4.0/DB2-CLI<br>#include &lt;otlv4.h&gt; // include the OTL 4.0 header file<br><pre><br><a
 href="otl3_connect_class.htm">otl_connect</a> db; // connect object<br><br><br>void select()<br>{&nbsp;<br>&nbsp;<a
 href="otl3_stream_class.htm">otl_stream</a> s;<br><br>&nbsp;s.set_all_column_types(otl_all_num2str|otl_all_date2str);&nbsp;<br>&nbsp;&nbsp;&nbsp; // map all numeric and date/time output columns to strings for simplicity.<br><br>&nbsp;s.open(100, // buffer size<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "$SQLTables",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // get a list of all tables in the current database<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; db // connect object<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );&nbsp;<br><br>&nbsp;otl_column_desc* desc;<br>&nbsp;int desc_len;<br>&nbsp;desc=s.describe_select(desc_len);&nbsp;<br>&nbsp;&nbsp;&nbsp; // describe the structure of the output columns of the result set.<br><br>&nbsp;int rpc=0;<br>&nbsp;while(!s.eof()){<br>&nbsp;&nbsp; ++rpc;<br>&nbsp;&nbsp; char str[512];<br>&nbsp;&nbsp; cout&lt;&lt;"ROW#"&lt;&lt;rpc&lt;&lt;" ";<br>&nbsp;&nbsp; for(int col_num=0;col_num&lt;desc_len;++col_num){<br>&nbsp;&nbsp;&nbsp;&nbsp; s&gt;&gt;str;<br>&nbsp;&nbsp;&nbsp;&nbsp; if(s.is_null())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;desc[col_num].name&lt;&lt;"=NULL ";<br>&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;desc[col_num].name&lt;&lt;"="&lt;&lt;str&lt;&lt;" ";<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; cout&lt;&lt;endl;<br>&nbsp;}<br><br>}<br><br>int main()<br>{<br>&nbsp;<a

⌨️ 快捷键说明

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