OCI8实施OCIStmtFetch2返回的是第二行,何解

OCI8执行OCIStmtFetch2返回的是第二行,何解?最近在写一个OCI接口的封装类.因早期是用OCI7,这次Oracle升级

OCI8执行OCIStmtFetch2返回的是第二行,何解?
最近在写一个OCI接口的封装类.因早期是用OCI7,这次Oracle升级到10G,需要改写OCI封装类.之前OCI7的时候,如完成Select col1,col2 from table1操作时的流程是:首先是连接数据库,接着Prepare前面的Select语句,然后执行绑定列操作,后面执行OCI7的oexec接口,最后ofetch,一行行的取回来.
为了保持这个流程,升级后的OCI8封装也必须按这个流程走,避免其它调用这个OCI封装类的程序全部要都要改动,到时只要重新编译一下程序即可.因此现在我的做法也是这样,先Prepare语句,然后绑定(绑定输出变量),然后调用OCI8的OCIStmtExecute,然后调用OCIStmtFetch2.单步的时候,发现执行完OCIStmtExecute后,绑定的变量已经有返回值了,是第一行的值.所以在执行OCIStmtFetch2的时候,游标已经到第二行了,返回的数据是表中第二行的数据.这是为何?
下面是Execute的代码.
 OCIStmtExecute(m_pcSvcCtx, m_pcStmt, m_pcError, (ub4) m_nStmtType, (ub4)0, 0, 0, OCI_DEFAULT);
Fetch的代码(这里返回的是第二行)
OCIStmtFetch2(m_pcStmt, m_pcError, (ub4)1, (ub2)OCI_FETCH_NEXT,(sb4)0, (ub4) OCI_DEFAULT)
[解决办法]
没用过oci
参考一下
Note: If output variables are defined for a SELECT statement before a
call to OCIStmtExecute(), the number of rows specified by iters will be
fetched directly into the defined output buffers and additional rows
equivalent to the prefetch count will be prefetched. If there are no
additional rows, then the fetch is complete without calling
OCIStmtFetch().
[解决办法]
你的这个变量m_nStmtType,值不会是1吧??
[解决办法]
第4个参数:
iters (IN) - the number of times this statement is executed for non-Select
statements. For Select statements, if iters is non-zero, then defines must
have been done for the statement handle. The execution fetches iters rows into
these predefined buffers and prefetches more rows depending upon the prefetch
row count. This function returns an error if iters=0 for non-SELECT
statements.