Sunday, March 25, 2007

Maximum Open Cursor Exceeded

Finding out what is the part of the code that doesn't close the connection or a ResultSet can be endless.
I'm still in the middle of my bug tracking :( but I found here some precious tips:

http://orafaq.com/node/758

In shortcuts, you can find below the main SQL that you'll report you how many opened cursors you currently have and which module/user acquired them:

select max(a.value) as highest_open_cur, p.value as max_open_cur from v$sesstat a, v$statname b, v$parameter p where a.statistic# = b.statistic# and b.name = 'opened cursors current' and p.name= 'open_cursors' group by p.value;

or

select a.value, s.username, s.sid, s.serial# from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic# and s.sid=a.sid and b.name = 'opened cursors current';

Or for a more compact view:

select sum(a.value) total_cur, avg(a.value) avg_cur, max(a.value) max_cur, s.username, s.machine from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic# and s.sid=a.sid and b.name = 'opened cursors current' group by s.username, s.machine order by 1 desc;


http://forums.oracle.com/forums/thread.jspa?threadID=487567&tstart=0