On Sep 15, 8:06 pm, Shane <gshanemil...@verizon.net> wrote:
> Thomas refers to OCIStmtFetch2() which does take an argument `nrows`
> described as "number of rows to be fetched from the current 
> position":http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci16m...
>
> 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 and drop 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.
>
> I guess it has to be the former (drops them in one by one) because
> Oracle is not telling me how may rows it *actually* gets on each fetch
> even though I request sets of 100.

You have to allocate memory for for an array. Your option #2.

Look up also OCI_PREFETCH_ROWS.
You can use (slow) fetch row by row in your program, but OCI does the
pre-fetch for you
on low level OCI.
HTH
Thomas

-- 
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to Oracle-PLSQL@googlegroups.com
To unsubscribe from this group, send email to
oracle-plsql-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en

Reply via email to