Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to stop an OCI query?

Re: How to stop an OCI query?

From: Dave Hau <davehau_nospam_123_at_nospam_netscape.net>
Date: Tue, 12 Aug 2003 19:53:19 GMT
Message-ID: <3F3945AD.8020503@nospam_netscape.net>


Try this:

sword result;

while (OCI_SUCCESS == (result = OCIStmtFetch2(select, errhp, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT))
{

   // process fetched data associated with define handles }

if (result == OCI_NO_DATA)
{

   // return success
}
else
{

   // return error
}

Cheers,
Dave

Ramon F Herrera wrote:
> What's the correct condition to check in order to stop
> a running OCI query? I have tried several approaches
> (see below) but I can't seem to find the right one.
>
> The following gives me too few records:
>
> while ((result = OCIStmtFetch2(select, errhp, 1, OCI_FETCH_NEXT, 0,
> OCI_DEFAULT)) == OCI_SUCCESS) {
> OCIStmtFetch2(select, errhp, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT);
> // retrieve record
> }
>
> And the following works sometimes but it can also result in too many
> iterations (infinite loop):
>
> while ((result = OCIStmtFetch2(select, errhp, 1, OCI_FETCH_NEXT, 0,
> OCI_DEFAULT)) == OCI_SUCCESS || result == OCI_ERROR) {
> OCIStmtFetch2(select, errhp, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT);
> // retrieve record
> }
>
>
> At some point I tried to run a COUNT(1) query first and then
> I queried for the actual data like this:
>
> for (i = 1; i <= numberOfRecords; i++) {
> OCIStmtFetch2(select, errhp, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT)
> // retrieve record
> }
>
> I am not even sure that the above code is working properly
> in all cases.
>
> This problem has been haunting me for a while. Thanks for
> your kind assistance...
>
> -Ramon F. Herrera
Received on Tue Aug 12 2003 - 14:53:19 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US