FIX: Oracle Cursor Limit Exceeded with Create MethodsLast reviewed: December 9, 1997Article ID: Q125227 |
The information in this article applies to:
- Professional Edition of Microsoft Visual Basic for Windows, version 3.0
SYMPTOMSWhen a Microsoft Visual Basic program uses the CreateDynaset or CreateSnapshot methods repeatedly, Oracle eventually runs out of cursors, and returns this error:
ODBC--call failed. [PageAhead][ODBC Oracle Driver][Oracle OCI] ORA-01000: maximum open cursors exceeded. (#1000) CAUSEEach SQL statement issued to an ODBC Data Source has an associated statement handle (hstmt) used to identify the statement. In Oracle, each hstmt uses a cursor. Cursors are a limited resource in Oracle and if the cursors are not dropped, the database will eventually run out. Visual Basic and the Microsoft Jet version 1.1 database engine allocate a new hstmt for each action SQL statement (INSERT, DELETE, UPDATE) executed by using the CreateDynaset and CreateSnapshot methods. However, neither Visual Basic nor the Jet database engine free the statement handle when closing the Dynaset or Snapshot. Instead, both rely on the freeing of the connection to perform these tasks. The Jet version 2.0 database engine is more aggressive about allocating and dropping statement handles. Each hstmt allocated is dropped when the Dynaset or Snapshot is closed. As a result, Oracle cursors are dropped along with the hstmt. The problem is evident when using the CreateDynaset or CreateSnapshot methods with the DB_SQLPassthrough flag (DB_SQLPassThrough=64) to issue action SQL statements to an Oracle database. Most developers use this method to avoid creating the additional connection to the server that the ExecuteSQL statement creates. The problem does not arise when using the CreateDynaset or CreateSnapshot methods to execute row returning queries, with or without the Passthrough option.
RESOLUTIONThe CreateDynaset and CreateSnapshot methods were not designed to run action queries. The Execute and ExecuteSQL methods are provided for those tasks. If a developer uses Execute or ExecuteSQL, VB uses the same hstmt for each action query and Oracle will not run out of cursors. To avoid exceeding the maximum number of cursors:
~ comlyr.exe (size: 741798 bytes)For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online Services Comlyr.exe is a self-extracting compressed file. Place the file in an empty directory and execute it. The file will expand and will produce the readme file (ACC2COMP.TXT) and SETUP.EXE. Run SETUP.EXE from File Manager to install the Compatibility Layer. STATUSThis problem has been fixed in Visual Basic 5.0.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional reference words: ODBC Oracle Cursor
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |