maximum open cursors exceeded with multiple OCIFetchStatement calls
| From: | waltb at rocketcash dot com | Date: | Thu, 23 Dec 1999 19:01:18 +0000 |
| Subject: | maximum open cursors exceeded with multiple OCIFetchStatement calls | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-8462@lists.php.net to get a copy of this message | ||
Howdy Folks,
I'm learning php, so be kind, but I'm having a problem with a for
loop that does
OCIFetchStatement/OCIFreeStatement pairs. After the first 500 or so
iterations I
get the error "maximum open cursors exceeded errors". I thought that
OCIFreeStatement
would free up any resources associated with a OCIFetchStatement call?
Due to the nature of the data and the tables, I can't really combine
the selects into 1 select.
For security reasons, I can't give the actual select satements.
Now I thought it was safe to have a loop with multiple
OCIFetchStatement's as long as I did a OCIFreeStatement at the end of
the loop?
$nrows turns out to be about 1500 in the case where I'm seeing the
problem. I know the
database's init.ora file has set the max open cursors to 2000.
Here is the jist of the script that I'm doing.
....
$query1 = "select email";
$query .= "from some_view where id=$this->id";
$stmt = OCIParse($conn, $query);
OCIError();
OCIExecute($stmt, OCI_DEFAULT);
OCIError($stmt);
$nrows = OCIFetchStatement($stmt, $results);
if ($nrows > 0)
{
for ($i=0; $i<$nrows; $i++)
{
/* This Query is to determine some stuff.*/
$query2 = "select stuff from table2 depending on data from
query1";
$stmt2 = OCIParse($conn, $query2);
OCIError();
OCIExecute($stmt2, OCI_DEFAULT);
OCIError($stmt2);
$nrows2 = OCIFetchStatement($stmt2, $results2);
/* This Query determines some other stuff. */
$query3 = "select blah blah from another table due to stuff
found from query2.";
$stmt3 = OCIParse($conn, $query3);
OCIError();
OCIExecute($stmt3, OCI_DEFAULT);
OCIError($stmt3);
$nrows3 = OCIFetchStatement($stmt3, $results3);
...
...
Work on the results from query2 and query3
...
...
OCIFreeStatement($stmt2);
OCIFreeStatement($stmt3);
}
}