|Oracle Call Interface Programmer's Guide
Part Number A89857-01
OCI Relational Functions, 36 of 39
This fetches a row from the (scrollable) result set. You are encouraged to use this fetch call instead of the deprecated call
sword OCIStmtFetch2 ( OCIStmt *stmthp, OCIError *errhp, ub4 nrows, ub2 orientation, sb4 fetchOffset, ub4 mode );
This is the statement handle of the (scrollable) result set.
An error handle you can pass to
OCIErrorGet() for diagnostic information in event of an error.
Number of rows to be fetched from the current position.
The acceptable values are:
fetchOffsetparameter) in the result set using absolute positioning.
fetchOffsetparameter) in the result set using relative positioning.
The offset to be used with the orientation parameter for changing the current row position.
Pass in OCI_DEFAULT.
OCIStmtFetch()call with the addition of the
fetchOffsetparameter. It can be used on any statement handle, whether it is scrollable or not. For a non-scrollable statement handle, the only acceptable value of
orientationis OCI_FETCH_NEXT, and the
fetchOffsetparameter will be ignored. For new applications you are encouraged to use this new call,
orientationset to OCI_FETCH_RELATIVE is equivalent to all of the following:
fetchOffsetequal to 0,
fetchOffsetequal to 1,
fetchOffsetequal to -1.
All other orientation modes besides OCI_FETCH_ABSOLUTE and OCI_FETCH_RELATIVE will ignore the
This call can also be used to find out the number of rows in the result set by using OCI_FETCH_LAST, and then calling
OCIAttrGet() on OCI_ATTR_CURRENT_POSITION. But the response time of this call can be high.
The return codes are the same as for
OCIStmtFetch(), except that OER(1403) with return code OCI_NO_DATA will be returned every time a fetch on a scrollable statement handle (or execute) is made and not all rows requested by the application could be fetched.
The scrollable statement handle will need to be explicitly cancelled (that is, fetch with 0 rows) or freed in order to release server-side resources for this scrollable cursor. A non-scrollable statement handle is implicitly cancelled on receiving the OER(1403).
Use OCI_ATTR_ROWS_FETCHED to find the number of rows that were successfully fetched into the user's buffers in the last fetch call.
"Scrollable Cursors" for more information on this topic