I am facing a problem on Oracle9i related to open cursors, ie ref cursors. When I am connecting to the database...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
through the connection pool, I find the number of open cursors increasing to about 500, when only two users are working. I took care of the closing of result sets and statements. Can I have useful information on this?
There are two types of cursors, implicit and explicit cursors. In PL/SQL, you create an explicit cursor with the CURSOR declaration. In JDBC programs, you create an explicit cursor for any SQL statement you pass to the database.
But sometimes, the database will create cursors for you. Any time the database creates a cursor for you that you have not explicitly stated, this is called an implicit cursor. Why does the system do this? The main reason is to handle all of the recursive SQL statements the system generates on your behalf. When you query a table, the system needs to query the data dictionary to see if that table exists, if you have permissions to view that table, etc.
The bottom line is that you are seeing open cursors for recursive SQL statements. Just enable SQL_TRACE for your session to see all of the recursive SQL being generated for you!
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.