?? otl4_ex612.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 612 (SQL statement label)</title>
</head>
<body>
<center>
<h1>OTL 4.0, Example 612 (SQL statement label)</h1>
</center>
This example demonstrates SQL statement labels and Oracle 8, 8i, 9i.
<h2>Source Code</h2>
<pre>#include <iostream><br>using namespace std;<br>#include <stdio.h><br><br>#define <a
href="otl3_compile.htm#OTL_ODBC_ENTERPRISEDB">OTL_ODBC_ENTERPRISEDB</a> // Compile OTL 4.0/EnterpriseDB-ODBC<br>// Uncomment the #define below when used in Linux / Unix<br>//#define OTL_ODBC_UNIX<br>#include <otlv4.h> // 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>{ <br> <a
href="otl3_stream_class.htm">otl_stream</a> i(50, // buffer size<br> "select * from test_tabxxx where f1>=:f11<int> and f1<=:f12<int>*2",<br> // SELECT statement<br> db, // connect object<br> 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> "SQL Stm #1" // SQL statement label.<br> ); <br> // create select stream<br> <br> float f1;<br> char f2[31];<br><br> i<<8<<8; // assigning :f11 = 8, :f12 = 8<br> // SELECT automatically executes when all input variables are<br> // assigned. First portion of output rows is fetched to the buffer<br><br> while(!i.eof()){ // while not end-of-data<br> i>>f1>>f2;<br> cout<<"f1="<<f1<<", f2="<<f2<<endl;<br> }<br><br> i<<4<<4; // assigning :f11 = 4, :f12 = 4<br> // SELECT automatically executes when all input variables are<br> // assigned. First portion of output rows is fetched to the buffer<br><br> while(!i.eof()){ // while not end-of-data<br> i>>f1>>f2;<br> cout<<"f1="<<f1<<", f2="<<f2<<endl;<br> }<br><br>}<br><br>int main()<br>{<br> <a
href="otl3_connect_class.htm">otl_connect::otl_initialize</a>(); // initialize ODBC environment<br> try{<br><br> db.rlogon("scott/tiger@edbsql"); // connect to EDB<br><br> select(); // select records from table<br><br> }<br><br> catch(<a
href="otl3_exception_class.htm">otl_exception</a>& p){ // intercept OTL exceptions<br> cerr<<p.msg<<endl; // print out error message<br> cerr<<p.stm_text<<endl; // print out SQL that caused the error<br> cerr<<p.var_info<<endl; // print out the variable that caused the error<br> }<br><br> db.logoff(); // disconnect from Oracle<br><br> return 0;<br><br>}</pre><br><h2><br>Output</h2><br><pre>ERROR: relation "test_tabxxx" does not exist;<br>Error while executing the query<br>SQL Stm #1<br><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 © 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 + -