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

📄 otl4_ex651.htm

📁 ISO_C++:C++_OTL开发文档
💻 HTM
字号:
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
  <meta content="text/html; charset=iso-8859-1"
 http-equiv="Content-Type">
  <meta content="Sergei Kuchin" name="Author">
  <meta content="Mozilla/4.77 [en] (Win95; U) [Netscape]"
 name="GENERATOR">
  <meta
 content="OTL, Oracle, ODBC, DB2, CLI, database API, C++, Template Library"
 name="KeyWords">
  <title>OTL 4.0, Example 651 (SQL statement label)</title>
</head>
<body>
<center>
<h1>OTL 4.0, Example 651 (SQL statement label)</h1>
</center>
This example demonstrates SQL statement labels.<br>
<h2>Source Code</h2>
<pre>#include &lt;iostream&gt;<br>using namespace std;<br>#include &lt;stdio.h&gt;<br><br>// Compile OTL 4.0/ODBC in Windows. Informix CLI uses the  <br>// regular ODBC header files in Windows<br>#define <a
 href="otl3_compile.htm#OTL_ODBC">OTL_ODBC</a> <br><br>// Uncomment the #defines below in Linux / Unix<br>//#define <a
 href="otl3_compile.htm#OTL_ODBC_UNIX">OTL_ODBC_UNIX</a><br>//#define <a
 href="otl3_compile.htm#OTL_INFORMIX_CLI">OTL_INFORMIX_CLI</a><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>void select()<br>{&nbsp;<br>&nbsp;<a
 href="otl3_stream_class.htm">otl_stream</a> i(50, // buffer size<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "select * from test_tabxxx where f1&gt;=:f11&lt;int&gt; and f1&lt;=:f12&lt;int&gt;*2",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // SELECT statement<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; db, // connect object<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; otl_explicit_select, // this parameter has the default value of "explicit select",<br>                                   // yet it has to be specified because of the next parameter<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "SQL Stm #1" // SQL statement label.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );&nbsp;<br>&nbsp;&nbsp; // create select stream<br>&nbsp;<br>&nbsp;float f1;<br>&nbsp;char f2[31];<br><br>&nbsp;i&lt;&lt;8&lt;&lt;8; // assigning :f11 = 8, :f12 = 8<br>&nbsp;&nbsp; // SELECT automatically executes when all input variables are<br>&nbsp;&nbsp; // assigned. First portion of output rows is fetched to the buffer<br><br>&nbsp;while(!i.eof()){ // while not end-of-data<br>&nbsp; i&gt;&gt;f1&gt;&gt;f2;<br>&nbsp; cout&lt;&lt;"f1="&lt;&lt;f1&lt;&lt;", f2="&lt;&lt;f2&lt;&lt;endl;<br>&nbsp;}<br><br>&nbsp;i&lt;&lt;4&lt;&lt;4; // assigning :f11 = 4, :f12 = 4<br>&nbsp;&nbsp; // SELECT automatically executes when all input variables are<br>&nbsp;&nbsp; // assigned. First portion of output rows is fetched to the buffer<br><br>&nbsp;while(!i.eof()){ // while not end-of-data<br>&nbsp; i&gt;&gt;f1&gt;&gt;f2;<br>&nbsp; cout&lt;&lt;"f1="&lt;&lt;f1&lt;&lt;", f2="&lt;&lt;f2&lt;&lt;endl;<br>&nbsp;}<br><br>}<br><br>int main()<br>{<br>&nbsp;<a
 href="otl3_connect_class.htm">otl_connect::otl_initialize</a>(); // initialize Informix CLI environment<br>&nbsp;try{<br><br>&nbsp; db.rlogon("informix/tigger@informixsql"); // connect to Informix<br><br>&nbsp; select(); // select records from table<br><br>&nbsp;}<br><br>&nbsp;catch(<a
 href="otl3_exception_class.htm">otl_exception</a>&amp; p){ // intercept OTL exceptions<br>&nbsp; cerr&lt;&lt;p.msg&lt;&lt;endl; // print out error message<br>&nbsp; cerr&lt;&lt;p.stm_text&lt;&lt;endl; // print out SQL that caused the error<br>&nbsp; cerr&lt;&lt;p.var_info&lt;&lt;endl; // print out the variable that caused the error<br>&nbsp;}<br><br>&nbsp;db.logoff(); // disconnect from Informix<br><br>&nbsp;return 0;<br><br>}</pre><br><h2><br>Output</h2><pre>[Informix][Informix ODBC Driver][Informix]The specified table (test_tabxxx) is not in the database.<br>SQL Stm #1<br></pre></pre>
<hr width="100%">
<center>
<p><a href="otl3_examples.htm">Examples</a> <a href="otl3.htm">Contents</a>
<a href="home.htm">Go Home</a> </p>
</center>
<p>Copyright &copy; 1996, 2008, Sergei Kuchin, email: <a
 href="mailto:skuchin@aceweb.com">skuchin@aceweb.com</a>,
<a href="mailto:skuchin@gmail.com">skuchin@yahogmail</a>
<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>.</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>
<pre><p><i></i>
</p>
</pre>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5456201-1");
pageTracker._trackPageview();
</script>
</body>
</html>

⌨️ 快捷键说明

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