-
Notifications
You must be signed in to change notification settings - Fork 366
max open cursors for Stored Procedure that returns nested SYS-REFCURSORs #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide the contents of the packaged procedure? I'd like to make sure that I can replicate the situation without making any guesses. The code to iterate over each child cursor doesn't need to be that complicated, I believe -- and that may be part of the problem -- but I'd like to confirm with the code you are using. |
Sure thing. I have anonymized the PL/SQL code, but the structure is identical:
The first child cursor is usually very shallow with only 1 - 15 integer values. The second child cursor can vary between 1 - 250 integer values. |
Thanks. How many rows are in the master table? |
There are a little over 2 million rows in the parent table. Also, I just ran updated queries on the child data tables. The first child cursor will return an average of 3 integers for every parent row and the second child cursor will return an average of 5 integers for every parent row. There are a couple of outliers in the second child cursor that will return 2500 integers. Thank you! |
I am able to replicate the problem with 5.3 but not with 6.0b1. Perhaps you can try that version and confirm? I will look into 5.3 further tomorrow. |
This issue has now been corrected on the v5.x branch using the same approach used on the master branch (released in 6.0b1). |
I am calling a stored procedure via cursor.callproc in an Oracle 12.1.0.2 database that returns a sys_refcursor. There are 16 scalar data elements and two child sys_refcursors within the parent cursor.
My Python program simply attempts to iterate the cursors. For each parent cursor row/iteration, I explicitly create the child cursors, iterate them and close them. I am running into "ORA-01000: maximum open cursors exceeded" when the program attempts to iterate the 101st parent row.
open_cursors is set to 300 in my database. When I monitor v$session, v$open_cursor, etc., I can see that for each parent row/iteration, there is 1 open cursor for the parent and 100 cursors open for each child cursor.
It would seem that cursor.close() is not actually closing the child cursor. I can call the same stored procedure with PL/SQL and iterate the result set without issue. I would prefer to keep the nested cursors. Is there a method to close them as I iterate that actually closes them on the server side?
Environment:
Oracle 12.1.0.2 on RHEL 7
Python 3.5.2 64-bit
cx_Oracle 5.3-12c 64-bit
Windows 7 Enterprise SP1 64-bit client
Oracle 12.1.0.2 Instant Client 64-bit
Example code:
The text was updated successfully, but these errors were encountered: