Home » Developer & Programmer » Precompilers, OCI & OCCI » OCIStmtFetch2() nrows argument (Oracle/10.2.0.4.0/Solaris)
OCIStmtFetch2() nrows argument [message #475588] Wed, 15 September 2010 23:17
gshanemiller@verizon.net
Messages: 4
Registered: May 2009
Junior Member
Re: OCIStmtFetch2() takes an argument `nrows` described as "number of rows to be fetched from the current position"

My select is something like: "select id,quantity,date from ord order by id". Each column is a plain-jane integer. One has to call OCIDefineByPos() for each column returned in the select. So I run three calls to OCIDefineByPos() to one integer:

int id,qty,date;
OCIDefineByPos ( ..., 1, ..., &id, sizeof(int), SQLT_INT );
OCIDefineByPos ( ..., 2, ..., &qty, sizeof(int), SQLT_INT );
OCIDefineByPos ( ..., 3, ..., &date, sizeof(int), SQLT_INT );

Then run the SQL:

rval = OCIStmtExecute ( ... )
while( rval != OCI_NO_DATA )
{
std::cout << "id: " << id << ... std::endl;
rval = OCIStmtFetch2( ..., 100, OCI_FETCH_NEXT, 0,
OCI_DEFAULT );
}

The point of all this: When I call OCIStmtFetch2() does Oracle
automagically & efficiently grab 100 rows at a time from the server and send to client dropping them one by one into by defined variables (id,qty,date) or should I have OCIDefineByPos'd to an array of 100 ids, 100 qtys, and 100 dates so that Oracle can drop each set of 100 into my array?

In otherwords OCIStmtFetch2() seems to allow me to grab X rows per call to OCIStmtFetch2() but what I don't understand is how to access each individual row like I do in the cout line. Presumably getting rows in sets like this is faster than one at a time?

I am doing this for a large table scan.
Previous Topic: extproc OCI LOB Question
Next Topic: compressed oracle connections
Goto Forum:
  


Current Time: Thu Mar 28 12:40:55 CDT 2024