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

📄 group__g__fetch.html

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 HTML
📖 第 1 页 / 共 5 页
字号:
                OCI_GetColumnSize(col));    }    <a class="code" href="group__g__init.html#g639706aa8e9689c7ebffc018fac6d3ae" title="Clean up all resources allocated by the library.">OCI_Cleanup</a>();     <span class="keywordflow">return</span> EXIT_SUCCESS;}</pre></div></dd></dl><dl class="user" compact><dt><b>Ref cursor Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="preprocessor">#include "ocilib.h"</span><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>){    <a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *cn;    <a class="code" href="struct_o_c_i___statement.html" title="Oracle SQL or PL/SQL statement.">OCI_Statement</a>  *st;    <a class="code" href="struct_o_c_i___resultset.html" title="Collection of output columns from a select statement.">OCI_Resultset</a>  *rs;    <span class="keywordflow">if</span> (!<a class="code" href="group__g__init.html#gcdb642d75f7c8478e083634144bc813c" title="Initializes the library.">OCI_Initialize</a>(NULL, NULL, OCI_ENV_DEFAULT))        <span class="keywordflow">return</span> EXIT_FAILURE;    cn = <a class="code" href="group__g__connect.html#gdb6e2cdf759587dd81c2fda7c5f44338" title="Create a physical connection to an Oracle database server.">OCI_ConnectionCreate</a>(<span class="stringliteral">"db"</span>, <span class="stringliteral">"usr"</span>, <span class="stringliteral">"pwd"</span>, OCI_SESSION_DEFAULT);     st = <a class="code" href="group__g__exec.html#g335822f983af0fb5c529431f06a9a17b" title="Create a statement object and return its handle.">OCI_StatementCreate</a>(cn);    <a class="code" href="group__g__exec.html#gf2163ec44e644cc734c393188707985b" title="Parse and execute a SQL statement or PL/SQL block.">OCI_ExecuteStmt</a>(st, <span class="stringliteral">"select article, cursor(select sysdate from dual) from test_fetch"</span>);        rs = <a class="code" href="group__g__fetch.html#gf2a9e28b66a9538ba0ffb62bffb87c16" title="Retrieve the resultset handle from an executed statement.">OCI_GetResultset</a>(st);    <span class="keywordflow">while</span> (<a class="code" href="group__g__fetch.html#g36ac26dcea78f6074421781e401f97ba" title="Fetch the next row of the resultset.">OCI_FetchNext</a>(rs))    {        <a class="code" href="struct_o_c_i___statement.html" title="Oracle SQL or PL/SQL statement.">OCI_Statement</a> *st2 = <a class="code" href="group__g__fetch.html#g9b73fe347ad581a6493845e6d0c3d04d" title="Return the current cursor value (Nested table) of the column at the given index in...">OCI_GetStatement</a>(rs, 2);        <a class="code" href="struct_o_c_i___resultset.html" title="Collection of output columns from a select statement.">OCI_Resultset</a> *rs2 = <a class="code" href="group__g__fetch.html#gf2a9e28b66a9538ba0ffb62bffb87c16" title="Retrieve the resultset handle from an executed statement.">OCI_GetResultset</a>(st2);        <span class="keywordflow">while</span> (<a class="code" href="group__g__fetch.html#g36ac26dcea78f6074421781e401f97ba" title="Fetch the next row of the resultset.">OCI_FetchNext</a>(rs2))        {            printf(<span class="stringliteral">"article : %s, sysdate : %s\n"</span>,                        <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 1),                   <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs2, 1));        }    }         <span class="keywordflow">return</span> EXIT_SUCCESS;}</pre></div></dd></dl><dl class="user" compact><dt><b>Scrollable resultset Example</b></dt><dd><div class="fragment"><pre class="fragment"><span class="preprocessor">#include "ocilib.h"</span><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>){    <a class="code" href="struct_o_c_i___connection.html" title="Oracle physical connection.">OCI_Connection</a> *cn;    <a class="code" href="struct_o_c_i___statement.html" title="Oracle SQL or PL/SQL statement.">OCI_Statement</a> *st;    <a class="code" href="struct_o_c_i___resultset.html" title="Collection of output columns from a select statement.">OCI_Resultset</a> *rs;    <span class="keywordflow">if</span> (!<a class="code" href="group__g__init.html#gcdb642d75f7c8478e083634144bc813c" title="Initializes the library.">OCI_Initialize</a>(NULL, NULL, OCI_ENV_DEFAULT))       <span class="keywordflow">return</span> EXIT_FAILURE;    cn = <a class="code" href="group__g__connect.html#gdb6e2cdf759587dd81c2fda7c5f44338" title="Create a physical connection to an Oracle database server.">OCI_ConnectionCreate</a>(<span class="stringliteral">"db"</span>, <span class="stringliteral">"usr"</span>, <span class="stringliteral">"pwd"</span>, OCI_SESSION_DEFAULT);    st = <a class="code" href="group__g__exec.html#g335822f983af0fb5c529431f06a9a17b" title="Create a statement object and return its handle.">OCI_StatementCreate</a>(cn);    <a class="code" href="group__g__stmt.html#g83e1c31e40926a84651eb60fefd50d5e" title="Set the fetch mode of a SQL statement.">OCI_SetFetchMode</a>(st, OCI_SFM_SCROLLABLE);    <a class="code" href="group__g__exec.html#gf2163ec44e644cc734c393188707985b" title="Parse and execute a SQL statement or PL/SQL block.">OCI_ExecuteStmt</a>(st, <span class="stringliteral">"select int_col1, str_col from my_table"</span>);       rs = <a class="code" href="group__g__fetch.html#gf2a9e28b66a9538ba0ffb62bffb87c16" title="Retrieve the resultset handle from an executed statement.">OCI_GetResultset</a>(st);      <span class="comment">/* get resultset row count */</span>    <a class="code" href="group__g__fetch.html#gb2b3f30ace2a89b07dd7803c82a523e7" title="Fetch the last row of the resultset.">OCI_FetchLast</a>(rs);    printf(<span class="stringliteral">"resultset contains %i rows\n"</span>, <a class="code" href="group__g__fetch.html#g93bd9197720088dbda2bef593ad1c07c" title="Retrieve the number of rows fetched so far.">OCI_GetRowCount</a>(rs));    <span class="comment">/* go to row 1 */</span>    <a class="code" href="group__g__fetch.html#gf26bde3f9db77231d66107af24a51d96" title="Fetch the first row of the resultset.">OCI_FetchFirst</a>(rs);    printf(<span class="stringliteral">"%i - %s\n"</span>, <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1), <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2));    <span class="comment">/* enumerate from row 2 to row X */</span>    <span class="keywordflow">while</span> (<a class="code" href="group__g__fetch.html#g36ac26dcea78f6074421781e401f97ba" title="Fetch the next row of the resultset.">OCI_FetchNext</a>(rs))        printf(<span class="stringliteral">"%i - %s\n"</span>, <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1), <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2));    <span class="comment">/* enumerate from row X back to row 1 */</span>    <span class="keywordflow">while</span> (<a class="code" href="group__g__fetch.html#g81e501b509b84d999e4337e2e11a90ec" title="Fetch the previous row of the resultset.">OCI_FetchPrev</a>(rs))        printf(<span class="stringliteral">"%i - %s\n"</span>, <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1), <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2));    <span class="comment">/* print the 30th row */</span>    <a class="code" href="group__g__fetch.html#g99372dc21a4965ca74d8fdde2069cc10" title="Custom Fetch of the resultset.">OCI_FetchSeek</a>(rs, OCI_SFD_ABSOLUTE,  30);    printf(<span class="stringliteral">"%i - %s\n"</span>, <a class="code" href="group__g__fetch.html#g4add0a9c53a23b334197c655b46b620c" title="Retrieve the current row number.">OCI_GetCurrentRow</a>(rs), <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1), <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2));    <span class="comment">/* fetch next 30 rows */</span>    <span class="keywordflow">while</span> ((<a class="code" href="group__g__fetch.html#g4add0a9c53a23b334197c655b46b620c" title="Retrieve the current row number.">OCI_GetCurrentRow</a>(rs) &lt; 60) &amp;&amp; <a class="code" href="group__g__fetch.html#g36ac26dcea78f6074421781e401f97ba" title="Fetch the next row of the resultset.">OCI_FetchNext</a>(rs))        printf(<span class="stringliteral">"%0i - %s\n"</span>, <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1), <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2));    <span class="comment">/* move back to the 45th row */</span>    <a class="code" href="group__g__fetch.html#g99372dc21a4965ca74d8fdde2069cc10" title="Custom Fetch of the resultset.">OCI_FetchSeek</a>(rs, OCI_SFD_RELATIVE,  -15);    printf(<span class="stringliteral">"%i - %s\n"</span>, <a class="code" href="group__g__fetch.html#ga8d80dc30b2012eaddd13efa9dfb711d" title="Return the current integer value of the column at the given index in the resultset...">OCI_GetInt</a>(rs, 1), <a class="code" href="group__g__fetch.html#g755a9b07c174feacd05c86e0e44b0ab0" title="Return the current string value of the column at the given index in the resultset...">OCI_GetString</a>(rs, 2));   <a class="code" href="group__g__init.html#g639706aa8e9689c7ebffc018fac6d3ae" title="Clean up all resources allocated by the library.">OCI_Cleanup</a>();   <span class="keywordflow">return</span> EXIT_SUCCESS;}</pre></div> </dd></dl><p><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr>

⌨️ 快捷键说明

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