Posted By: faq FAQ: ORA-01000: maximum open cursors exceeded - 09/04/99 07:40 PM
After running my application for a while, I get an ORA-01000 error. How can I avoid this?
The ORA-01000 error is a very common problem. Every TOracleQuery, TOracleDataSet and TOraclePackage component linked to the same TOracleSession takes up one or more cursors from this session. The OPEN_CURSORS limit is a limit per session, not a transaction limit or system wide limit.

The default OPEN_CURSORS limit of 50 is too little for any major application, and should normally be increased to a value that is sufficient for your application. Increasing this parameter has no negative side effects, and makes better use of resources than the alternative: closing and opening cursors all the time for the same query.

To determine the value of the OPEN_CURSORS parameter that is sufficient for your application, you can make the following estimation:

OPEN_CURSORS = q + p + (2 * d)

Where q = the number of TOracleQuery components, p = the number of TOraclePackage components, and d = the number of TOracleDataSet components. This value will probably be more then is necessary in practice, because not
all queries and datasets will be "open" at the same time.

The ORA-01000 problem can also occur if you are creating and executing one of the components mentioned above without freeing it. The instance will remain in memory, and the corresponding database cursor will remain open.

For some applications it may be required that they can work with the default value of the OPEN_CURSORS initialization parameter. In that case you need to explicitly close TOracleQuery components after executing it and fetching the results. For TOracleDataSet components, calling Close does not free up both cursors. The cursor for the dataset's select statement remains open so that it can be immediately re-executed when the dataset is opened again. Call the CloseAll procedure to close all cursors.
© Allround Automations forums