📄 resultset_8c-source.html
字号:
<a name="l00394"></a>00394 <span class="keywordtype">boolean</span> OCI_FetchData(<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, <span class="keywordtype">boolean</span> *err)<a name="l00395"></a>00395 {<a name="l00396"></a>00396 <span class="keywordtype">boolean</span> res = TRUE;<a name="l00397"></a>00397 <a name="l00398"></a>00398 <span class="comment">/* let's initialize the error flag to TRUE until the process completes */</span><a name="l00399"></a>00399 <a name="l00400"></a>00400 *err = TRUE;<a name="l00401"></a>00401 <a name="l00402"></a>00402 <span class="comment">/* internal fetch */</span><a name="l00403"></a>00403 <a name="l00404"></a>00404 <span class="preprocessor">#if defined(OCI_STMT_SCROLLABLE_READONLY)</span><a name="l00405"></a>00405 <span class="preprocessor"></span><a name="l00406"></a>00406 <span class="keywordflow">if</span> (OCILib.use_scrollable_cursors == TRUE)<a name="l00407"></a>00407 {<a name="l00408"></a>00408 rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> = OCIStmtFetch2(rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#e526a309495dc7d8bcb747b2771de6b9">stmt</a>, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-><a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>,<a name="l00409"></a>00409 rs-><a class="code" href="struct_o_c_i___resultset.html#f1e985de777e4ab098b2183fc43e4612">fetch_size</a>, (ub2) mode, (sb4) offset,<a name="l00410"></a>00410 (ub4) OCI_DEFAULT);<a name="l00411"></a>00411 }<a name="l00412"></a>00412 <span class="keywordflow">else</span><a name="l00413"></a>00413 <span class="preprocessor">#endif</span><a name="l00414"></a>00414 <span class="preprocessor"></span> {<a name="l00415"></a>00415 rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> = OCIStmtFetch(rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#e526a309495dc7d8bcb747b2771de6b9">stmt</a>, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-><a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>,<a name="l00416"></a>00416 rs-><a class="code" href="struct_o_c_i___resultset.html#f1e985de777e4ab098b2183fc43e4612">fetch_size</a>, (ub2) OCI_FETCH_NEXT,<a name="l00417"></a>00417 (ub4) OCI_DEFAULT);<a name="l00418"></a>00418 }<a name="l00419"></a>00419 <a name="l00420"></a>00420 <span class="comment">/* check failure */</span><a name="l00421"></a>00421 <a name="l00422"></a>00422 <span class="keywordflow">if</span> (rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_ERROR)<a name="l00423"></a>00423 {<a name="l00424"></a>00424 OCI_ExceptionOCI(rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-><a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>);<a name="l00425"></a>00425 res = FALSE;<a name="l00426"></a>00426 }<a name="l00427"></a>00427 <a name="l00428"></a>00428 <span class="comment">/* do we need to do a piecewise fetch */</span><a name="l00429"></a>00429 <a name="l00430"></a>00430 <span class="keywordflow">if</span> (rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_NEED_DATA)<a name="l00431"></a>00431 res = OCI_FetchPieces(rs);<a name="l00432"></a>00432 <a name="l00433"></a>00433 <span class="comment">/* check string buffer for Unicode builds that need buffer expansion */</span><a name="l00434"></a>00434 <a name="l00435"></a>00435 <span class="preprocessor">#ifdef OCI_CHECK_DATASTRINGS</span><a name="l00436"></a>00436 <span class="preprocessor"></span><a name="l00437"></a>00437 OCI_ResultsetExpandStrings(rs);<a name="l00438"></a>00438 <a name="l00439"></a>00439 <span class="preprocessor">#endif</span><a name="l00440"></a>00440 <span class="preprocessor"></span><a name="l00441"></a>00441 <span class="comment">/* check for success */</span><a name="l00442"></a>00442 <a name="l00443"></a>00443 res = ((res == TRUE) && ((rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_SUCCESS) ||<a name="l00444"></a>00444 (rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_NO_DATA) ||<a name="l00445"></a>00445 (rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_SUCCESS_WITH_INFO)));<a name="l00446"></a>00446 <a name="l00447"></a>00447 <span class="comment">/* update internal fetch status and variables */</span><a name="l00448"></a>00448 <a name="l00449"></a>00449 <span class="keywordflow">if</span> (res == TRUE)<a name="l00450"></a>00450 {<a name="l00451"></a>00451 ub4 row_count = 0;<a name="l00452"></a>00452 ub4 row_fetched = 0;<a name="l00453"></a>00453 <a name="l00454"></a>00454 <span class="preprocessor">#if defined(OCI_STMT_SCROLLABLE_READONLY)</span><a name="l00455"></a>00455 <span class="preprocessor"></span><a name="l00456"></a>00456 <span class="keywordflow">if</span> (rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#806896e02653b85f4f6cfa5c70495a17">exec_mode</a> == OCI_SFM_SCROLLABLE)<a name="l00457"></a>00457 {<a name="l00458"></a>00458 OCI_CALL1<a name="l00459"></a>00459 (<a name="l00460"></a>00460 res, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>,<a name="l00461"></a>00461 <a name="l00462"></a>00462 OCIAttrGet((dvoid *) rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#e526a309495dc7d8bcb747b2771de6b9">stmt</a>, (ub4) OCI_HTYPE_STMT,<a name="l00463"></a>00463 (dvoid *) &row_count, (ub4 *) NULL,<a name="l00464"></a>00464 (ub4) OCI_ATTR_CURRENT_POSITION, rs-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>-><a class="code" href="struct_o_c_i___statement.html#338ddf58debd7de6ab9355f1e75d78f6">con</a>-><a class="code" href="struct_o_c_i___connection.html#573a359867139990b1b0f50aa7a86175">err</a>)<a name="l00465"></a>00465 )<a name="l00466"></a>00466 <a name="l00467"></a>00467 OCI_CALL1<a name="l00468"></a>00468 (<a name="l00469"></a>00469 res, rs->stmt->con, rs->stmt,<a name="l00470"></a>00470 <a name="l00471"></a>00471 OCIAttrGet((dvoid *) rs->stmt->stmt, (ub4) OCI_HTYPE_STMT,<a name="l00472"></a>00472 (dvoid *) &row_fetched, (ub4 *) NULL,<a name="l00473"></a>00473 (ub4) OCI_ATTR_ROWS_FETCHED, rs->stmt->con->err)<a name="l00474"></a>00474 )<a name="l00475"></a>00475 }<a name="l00476"></a>00476 else<a name="l00477"></a>00477 <span class="preprocessor">#endif</span><a name="l00478"></a>00478 <span class="preprocessor"></span> {<a name="l00479"></a>00479 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-><a class="code" href="struct_o_c_i___resultset.html#c12ae7da6f8d20f00c6ad69cdb31373a">stmt</a>);<a name="l00480"></a>00480 row_fetched = row_count - rs-><a class="code" href="struct_o_c_i___resultset.html#9c252a26f209b62a6f523dcf59ca9a0d">row_count</a>;<a name="l00481"></a>00481 <a name="l00482"></a>00482 }<a name="l00483"></a>00483 <a name="l00484"></a>00484 <span class="keywordflow">if</span> (rs-><a class="code" href="struct_o_c_i___resultset.html#9c252a26f209b62a6f523dcf59ca9a0d">row_count</a> < row_count)<a name="l00485"></a>00485 rs-><a class="code" href="struct_o_c_i___resultset.html#9c252a26f209b62a6f523dcf59ca9a0d">row_count</a> = row_count;<a name="l00486"></a>00486 <a name="l00487"></a>00487 <span class="keywordflow">if</span> (row_fetched > 0)<a name="l00488"></a>00488 rs-><a class="code" href="struct_o_c_i___resultset.html#1fb814eb9b03b65bd84d2e7551e29a28">row_fetched</a> = row_fetched;<a name="l00489"></a>00489 <a name="l00490"></a>00490 <span class="comment">/* so far, no OCI error occurred, let's clear the error flag */</span><a name="l00491"></a>00491 <a name="l00492"></a>00492 *err = FALSE;<a name="l00493"></a>00493 <a name="l00494"></a>00494 <span class="comment">/* check if internal fetch was successful */</span><a name="l00495"></a>00495 <a name="l00496"></a>00496 <span class="keywordflow">if</span> ((rs-><a class="code" href="struct_o_c_i___resultset.html#261b838dbeb0658e84d45a210542c7e8">fetch_status</a> == OCI_NO_DATA) && (row_fetched == 0))<a name="l00497"></a>00497 {<a name="l00498"></a>00498 <span class="keywordflow">if</span> ((mode == OCI_SFD_NEXT) || (offset > 0))<a name="l00499"></a>00499 rs-><a class="code" href="struct_o_c_i___resultset.html#3a4dd67805dca28105e9c9c32cc893fe">eof</a> = TRUE;<a name="l00500"></a>00500 <a name="l00501"></a>00501 <span class="keywordflow">if</span> (offset < 0)<a name="l00502"></a>00502 rs-><a class="code" href="struct_o_c_i___resultset.html#356238d1be7f437365b64f38af66305c">bof</a> = TRUE;<a name="l00503"></a>00503 <a name="l00504"></a>00504 res = FALSE;<a name="l00505"></a>00505 }<a name="l00506"></a>00506 }<a name="l00507"></a>00507 <a name="l00508"></a>00508 <span class="keywordflow">return</span> res;<a name="l00509"></a>00509 }<a name="l00510"></a>00510 <a name="l00511"></a>00511 <span class="comment">/* ------------------------------------------------------------------------ *</span><a name="l00512"></a>00512 <span class="comment"> * OCI_FetchCustom</span><a name="l00513"></a>00513 <span class="comment"> * ------------------------------------------------------------------------ */</span><a name="l00514"></a>00514 <a name="l00515"></a>00515 <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, <span class="keywordtype">boolean</span> *err)<a name="l00516"></a>00516 {<a name="l00517"></a>00517 <span class="keywordtype">boolean</span> res = TRUE;<a name="l00518"></a>00518 <a name="l00519"></a>00519 <span class="keywordflow">switch</span> (mode)<a name="l00520"></a>00520 {<a name="l00521"></a>00521 <span class="keywordflow">case</span> OCI_SFD_RELATIVE:<a name="l00522"></a>00522 {<a name="l00523"></a>00523 <span class="keywordtype">int</span> offset_save = 0;<a name="l00524"></a>00524 <a name="l00525"></a>00525 <span class="keywordflow">if</span> (((offset > 0) && (rs-><a class="code" href="struct_o_c_i___resultset.html#3a4dd67805dca28105e9c9c32cc893fe">eof</a> == TRUE)) ||<a name="l00526"></a>00526 ((offset < 0) && (rs-><a class="code" href="struct_o_c_i___resultset.html#356238d1be7f437365b64f38af66305c">bof</a> == TRUE)) ||<a name="l00527"></a>00527 (offset == 0))<a name="l00528"></a>00528 {<a name="l00529"></a>00529 res = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -