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

📄 resultset_8c-source.html

📁 ORACLE编程的好东西,纯C写的OCI封装.很好用,支持数据池.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00400"></a>00400 {<a name="l00401"></a>00401     <span class="keywordtype">boolean</span> res  = TRUE;<a name="l00402"></a>00402     <span class="comment">//OCI_CHECK(rs-&gt;fetch_status == OCI_NO_DATA, FALSE);</span><a name="l00403"></a>00403 <a name="l00404"></a>00404     <span class="comment">/* internal fetch */</span><a name="l00405"></a>00405 <a name="l00406"></a>00406 <span class="preprocessor">#if defined(OCI_STMT_SCROLLABLE_READONLY)</span><a name="l00407"></a>00407 <span class="preprocessor"></span><a name="l00408"></a>00408     <span class="keywordflow">if</span> (OCILib.use_scrollable_cursors == TRUE)<a name="l00409"></a>00409     {<a name="l00410"></a>00410         rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> = OCIStmtFetch2(rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#e526a309495dc7d8bcb747b2771de6b9">stmt</a>, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>,<a name="l00411"></a>00411                                          rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#f1e985de777e4ab098b2183fc43e4612">fetch_size</a>, (ub2) mode, (sb4) offset,<a name="l00412"></a>00412                                          (ub4) OCI_DEFAULT);<a name="l00413"></a>00413     }<a name="l00414"></a>00414     <span class="keywordflow">else</span><a name="l00415"></a>00415 <span class="preprocessor">#endif</span><a name="l00416"></a>00416 <span class="preprocessor"></span>    {<a name="l00417"></a>00417         rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> = OCIStmtFetch(rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#e526a309495dc7d8bcb747b2771de6b9">stmt</a>, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, <a name="l00418"></a>00418                                         rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#f1e985de777e4ab098b2183fc43e4612">fetch_size</a>, (ub2) OCI_FETCH_NEXT, <a name="l00419"></a>00419                                         (ub4) OCI_DEFAULT);   <a name="l00420"></a>00420     }<a name="l00421"></a>00421 <a name="l00422"></a>00422     <span class="comment">/* check failure */</span><a name="l00423"></a>00423 <a name="l00424"></a>00424     <span class="keywordflow">if</span> (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_ERROR)<a name="l00425"></a>00425     {<a name="l00426"></a>00426           OCI_ExceptionOCI(rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>);<a name="l00427"></a>00427           res = FALSE;<a name="l00428"></a>00428     }<a name="l00429"></a>00429 <a name="l00430"></a>00430     <span class="comment">/* do we need to do a piecewise fetch */</span><a name="l00431"></a>00431 <a name="l00432"></a>00432     <span class="keywordflow">if</span> (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_NEED_DATA)<a name="l00433"></a>00433         res = OCI_FetchPieces(rs);<a name="l00434"></a>00434 <a name="l00435"></a>00435     <span class="comment">/* check string buffer for unicode builds that need buffer expansion */</span><a name="l00436"></a>00436 <a name="l00437"></a>00437 <span class="preprocessor">#ifdef OCI_CHECK_DATASTRINGS </span><a name="l00438"></a>00438 <span class="preprocessor"></span> <a name="l00439"></a>00439     OCI_ResultsetExpandStrings(rs);<a name="l00440"></a>00440 <a name="l00441"></a>00441 <span class="preprocessor">#endif</span><a name="l00442"></a>00442 <span class="preprocessor"></span><a name="l00443"></a>00443     <span class="comment">/* check for success */</span><a name="l00444"></a>00444 <a name="l00445"></a>00445     res = ((res == TRUE) &amp;&amp; ((rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_SUCCESS) ||<a name="l00446"></a>00446                              (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_NO_DATA) ||<a name="l00447"></a>00447                              (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_SUCCESS_WITH_INFO)));<a name="l00448"></a>00448  <a name="l00449"></a>00449     <span class="comment">/* update internal fecth status and variables */</span><a name="l00450"></a>00450 <a name="l00451"></a>00451     <span class="keywordflow">if</span> (res == TRUE)<a name="l00452"></a>00452     {<a name="l00453"></a>00453         ub4 row_count      = 0;<a name="l00454"></a>00454         ub4 row_fetched    = 0;<a name="l00455"></a>00455 <a name="l00456"></a>00456 <span class="preprocessor">#if defined(OCI_STMT_SCROLLABLE_READONLY)</span><a name="l00457"></a>00457 <span class="preprocessor"></span><a name="l00458"></a>00458         <span class="keywordflow">if</span> (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#806896e02653b85f4f6cfa5c70495a17">exec_mode</a>  == OCI_SFM_SCROLLABLE)<a name="l00459"></a>00459         {<a name="l00460"></a>00460             OCI_CALL1<a name="l00461"></a>00461             (<a name="l00462"></a>00462                 res, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>,<a name="l00463"></a>00463 <a name="l00464"></a>00464                 OCIAttrGet((dvoid *) rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#e526a309495dc7d8bcb747b2771de6b9">stmt</a>, (ub4) OCI_HTYPE_STMT,<a name="l00465"></a>00465                            (dvoid *) &amp;row_count, (ub4 *) NULL, <a name="l00466"></a>00466                            (ub4) OCI_ATTR_CURRENT_POSITION, rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-&gt;<a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-&gt;<a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>)<a name="l00467"></a>00467             )<a name="l00468"></a>00468 <a name="l00469"></a>00469             OCI_CALL1<a name="l00470"></a>00470             (<a name="l00471"></a>00471                 res, rs-&gt;stmt-&gt;con, rs-&gt;stmt,<a name="l00472"></a>00472                 <a name="l00473"></a>00473                 OCIAttrGet((dvoid *) rs-&gt;stmt-&gt;stmt, (ub4) OCI_HTYPE_STMT, <a name="l00474"></a>00474                            (dvoid *) &amp;row_fetched, (ub4 *) NULL,<a name="l00475"></a>00475                            (ub4) OCI_ATTR_ROWS_FETCHED, rs-&gt;stmt-&gt;con-&gt;err)<a name="l00476"></a>00476             )<a name="l00477"></a>00477         }<a name="l00478"></a>00478         else<a name="l00479"></a>00479 <span class="preprocessor">#endif</span><a name="l00480"></a>00480 <span class="preprocessor"></span>        {<a name="l00481"></a>00481             row_count   = <a class="code" href="group__g__exec.html#g1cf932261960da80cd36d650a08565c3" title="Return the number of rows affected by the SQL statement.">OCI_GetAffectedRows</a>(rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>);<a name="l00482"></a>00482             row_fetched = row_count - rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#9c252a26f209b62a6f523dcf59ca9a0d">row_count</a>;<a name="l00483"></a>00483 <a name="l00484"></a>00484         }<a name="l00485"></a>00485 <a name="l00486"></a>00486         <span class="keywordflow">if</span> (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#9c252a26f209b62a6f523dcf59ca9a0d">row_count</a> &lt; row_count)<a name="l00487"></a>00487             rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#9c252a26f209b62a6f523dcf59ca9a0d">row_count</a> = row_count;<a name="l00488"></a>00488 <a name="l00489"></a>00489         <span class="keywordflow">if</span> (row_fetched &gt; 0)<a name="l00490"></a>00490             rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#1fb814eb9b03b65bd84d2e7551e29a28">row_fetched</a> = row_fetched;<a name="l00491"></a>00491 <a name="l00492"></a>00492         <span class="keywordflow">if</span> ((rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_NO_DATA) &amp;&amp; (row_fetched == 0))  <a name="l00493"></a>00493         {<a name="l00494"></a>00494             <span class="keywordflow">if</span> ((mode == OCI_SFD_NEXT) || (offset &gt; 0))<a name="l00495"></a>00495                 rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#3a4dd67805dca28105e9c9c32cc893fe">eof</a> = TRUE;<a name="l00496"></a>00496 <a name="l00497"></a>00497             <span class="keywordflow">if</span> (offset &lt; 0)<a name="l00498"></a>00498                 rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#356238d1be7f437365b64f38af66305c">bof</a> = TRUE;<a name="l00499"></a>00499 <a name="l00500"></a>00500             res = FALSE;<a name="l00501"></a>00501         }<a name="l00502"></a>00502     }<a name="l00503"></a>00503     <span class="keywordflow">else</span><a name="l00504"></a>00504         res = FALSE;<a name="l00505"></a>00505 <a name="l00506"></a>00506     <span class="keywordflow">return</span> res;<a name="l00507"></a>00507 }<a name="l00508"></a>00508 <a name="l00509"></a>00509 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00510"></a>00510 <span class="comment"> * OCI_FetchCustom</span><a name="l00511"></a>00511 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00512"></a>00512 <a name="l00513"></a>00513 <span class="keywordtype">boolean</span> OCI_FetchCustom(<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="keywordtype">int</span> mode, <span class="keywordtype">int</span> offset)<a name="l00514"></a>00514 { <a name="l00515"></a>00515     <span class="keywordtype">boolean</span> res = TRUE;<a name="l00516"></a>00516 <a name="l00517"></a>00517     <span class="keywordflow">switch</span> (mode)<a name="l00518"></a>00518     {<a name="l00519"></a>00519         <span class="keywordflow">case</span> OCI_SFD_RELATIVE:<a name="l00520"></a>00520         {<a name="l00521"></a>00521             <span class="keywordtype">int</span> offset_save = 0;<a name="l00522"></a>00522 <a name="l00523"></a>00523             <span class="keywordflow">if</span> (((offset &gt; 0) &amp;&amp; (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#3a4dd67805dca28105e9c9c32cc893fe">eof</a> == TRUE)) ||<a name="l00524"></a>00524                 ((offset &lt; 0) &amp;&amp; (rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#356238d1be7f437365b64f38af66305c">bof</a> == TRUE)) ||<a name="l00525"></a>00525                 (offset == 0))<a name="l00526"></a>00526             {<a name="l00527"></a>00527                 res = FALSE;<a name="l00528"></a>00528             }<a name="l00529"></a>00529             <span class="keywordflow">else</span><a name="l00530"></a>00530             {<a name="l00531"></a>00531                 offset_save = offset;<a name="l00532"></a>00532                 offset      = offset - rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#1fb814eb9b03b65bd84d2e7551e29a28">row_fetched</a> + rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#540ba8a96856cdbc89885745e7c6c72f">row_cur</a>;<a name="l00533"></a>00533                 rs-&gt;<a class="code" href="struct_o_c_i___resultset.html#540ba8a96856cdbc89885745e7c6c72f">row_cur</a> = 1;   <a name="l00534"></a>00534 <a name="l00535"></a>00535                 res = OCI_FetchData(rs, mode, offset);<a name="l00536"></a>00536 <a name="l00537"></a>00537                 <span class="keywordflow">if</span> (res == TRUE)

⌨️ 快捷键说明

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