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

📄 ex7_8c-example.html

📁 Linux下的操作oracle数据库的连接库
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>libsqlora8: Example Documentation</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <a class="qindex" href="examples.html">Examples</a></div><h1>ex7.c</h1>Example for using sqlo_fetch, sqlo_values, sqlo_ocol_name_lens, sqlo_ocol_names, sqlo_value_lens. <div class="fragment"><pre><span class="comment">/* $Id: ex7.c,v 1.6 2004/01/03 16:48:19 kpoitschke Exp $ */</span><span class="preprocessor">#include &lt;stdio.h&gt;</span><span class="preprocessor">#include &lt;stdlib.h&gt;</span><span class="preprocessor">#include "examples.h"</span><span class="keywordtype">int</span> do_select(<a class="code" href="group__typedefs.html#ga0">sqlo_db_handle_t</a> dbh, <span class="keywordtype">double</span> min_income){  <a class="code" href="group__typedefs.html#ga1">sqlo_stmt_handle_t</a> sth;       <span class="comment">/* statement handle */</span>  <span class="keywordtype">int</span> status;                   <span class="comment">/* status of sqlo calls */</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i,j;                      <span class="comment">/* loop counter */</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> ** v;              <span class="comment">/* values */</span>  <span class="keyword">const</span> <span class="keywordtype">char</span> ** col_names;      <span class="comment">/* column names */</span>  CONST <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *nl;       <span class="comment">/* column name lengths */</span>  CONST <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> *vl;     <span class="comment">/* value lengths */</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nc;              <span class="comment">/* number of columns */</span>  sth = reopen_cursor(dbh, min_income); <span class="comment">/* see example of sqlo_reopen (ex6.c) */</span>  <span class="comment">/* get the output column names */</span>  status = <a name="a73"></a><a class="code" href="group__easy.html#ga196">sqlo_ocol_names2</a>(sth, &amp;nc, &amp;col_names);  <span class="keywordflow">if</span> (0 &gt; status) {    error_exit(dbh, <span class="stringliteral">"sqlo_ocol_names2"</span>);  }  <span class="comment">/* get the output column name lengths */</span>  nl = <a name="a74"></a><a class="code" href="group__easy.html#ga197">sqlo_ocol_name_lens</a>(sth, NULL);  printf(<span class="stringliteral">"Employees with SAL &gt; %-8.2f:\n"</span>, min_income);  <span class="comment">/* print the header */</span>  <span class="keywordflow">for</span> (i = 0; i &lt; nc; ++i)    printf(<span class="stringliteral">"%-*s "</span>, nl[i], col_names[i]);  printf(<span class="stringliteral">"\n"</span>);  <span class="keywordflow">for</span> (i = 0; i &lt; nc; ++i) {    <span class="keywordflow">for</span> (j = 0; j &lt; nl[i]; ++j) {      putchar(<span class="charliteral">'-'</span>);    }    putchar(<span class="charliteral">'+'</span>);  }  putchar(<span class="charliteral">'\n'</span>);  <span class="comment">/* fetch the data */</span>  <span class="keywordflow">while</span> ( <a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> == (status = (<a name="a75"></a><a class="code" href="group__easy.html#ga167">sqlo_fetch</a>(sth, 1)))) {        <span class="comment">/* get one record */</span>    v = <a name="a76"></a><a class="code" href="group__easy.html#ga168">sqlo_values</a>(sth, NULL, 1);    <span class="comment">/* get the length of the data items */</span>    vl = <a name="a77"></a><a class="code" href="group__easy.html#ga198">sqlo_value_lens</a>(sth, NULL);    <span class="comment">/* print the column values */</span>    <span class="keywordflow">for</span> (i = 0; i &lt; nc; ++i)      printf(<span class="stringliteral">"%-*s "</span>, (vl[i] &gt; nl[i] ? vl[i] : nl[i]), v[i]);    printf(<span class="stringliteral">"\n"</span>);  }  <span class="keywordflow">if</span> (0 &gt; status) {    error_exit(dbh, <span class="stringliteral">"sqlo_fetch"</span>);  }  <span class="keywordflow">if</span> ( <a class="code" href="group__constants.html#gga3a25">SQLO_SUCCESS</a> != <a name="a78"></a><a class="code" href="group__easy.html#ga172">sqlo_close</a>(sth))    error_exit(dbh, <span class="stringliteral">"sqlo_close"</span>);  <span class="keywordflow">return</span> 1;}<span class="comment">/* $Id: ex7.c,v 1.6 2004/01/03 16:48:19 kpoitschke Exp $ */</span></pre></div> <hr size="1"><address style="align: right;"><small>Generated on Sun Jun 13 04:51:41 2004 for libsqlora8 by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.6 </small></address></body></html>

⌨️ 快捷键说明

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