Maximum open cursor reached issue in Vb.net application connecting to Oracle database

Hi Experts,

I'm having an issue of oracle cursor in my VB.net application. I'm using Oracle connection to connect to Oracle DB, and have a transaction. Within transaction there are insert and select statement. When oracle reaches to its maximum cursor defined in oracle DB, it's throwing an exception of "Maximum open cursor reached" in Vb.net application.  

Since I'm using transaction, I cannot close the connection until transaction is done. I don't know why "ExecuteNonQuery" is creating a new cursor. If i have 1000 records in transaction, it's opening 1000 cursor in the DB, one cursor for each "ExecuteNonQuery"

Is there any way to avoid this cursor issue? I already tried disposing the command object but no luck.
ArikkanAsked:
Who is Participating?
 
ArikkanAuthor Commented:
It was an issue with ExecuteDataReader, and closing the datareader object solved the issue.

Thanks everyone for your help..
0
 
Mark GeerlingsDatabase AdministratorCommented:
I don't use VB, so I can't help you inside VB.  But, could you write your code in PL\SQL instead and compile it as a stored procedure that can accept input parameters, then call that procedure from your VB.net application?
0
 
ArikkanAuthor Commented:
The issue is not with Input parameter. It's creating cursor for each "ExecuteNonQuery" function. even if we use stored procedure "ExecuteNonQuery" needs to be executed.
0
 
Mark GeerlingsDatabase AdministratorCommented:
But, if all of the logic is in PL\SQL instead of in VB, you may need to make only one call to "ExecuteNonQuery", that is, assuming you can pass the values needed to PL\SQL in the one procedure call.  Or, you may be able to create and populate  a "work" table with the parameter values you need, then have the PL\SQL procedure use a cursor loop to fetch each set of values from the work table and do the Oracle processing that you need.
0
 
ArikkanAuthor Commented:
I did resolve it by myself
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.