Page 1 of 1

Find out Opened Cursors and the related Objects

Posted: Tue Mar 10, 2009 4:16 am
by keerti_rose
Hi Floks,

I have a procedure with 10 Cursors declared in that..Out of 10 i have closed 9 Cursors ...Means i haven't closed one cursor..After that I have given it to some body and they got execute the same and got the results in a proper way...But i want to know the details of that coursor information without opening and looking into that code.

Is there anyway to findout Obect Name,Cursor name which was not closed in that Object?

Please help me in this...Thanks

Posted: Sun May 31, 2009 11:09 pm
by amirtai
Hi there

Here are few ways to monitor open cursors, that'll give you some idea.

To monitor open cursors, query v$sesstat where name='opened cursors current'. This will give the number of currently opened cursors, by session:

--total cursors open, by session
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';

If you're running several N-tiered applications with multiple webservers, you may find it useful to monitor open cursors by username and machine:

--total cursors open, by username & machine
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;

Amir