File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ REM Script Name : tp_open_cursors .sql
2
+ REM Author : Craig Richards
3
+ REM Created : 27 September 2013
4
+ REM Last Modified :
5
+ REM Version : 1 .0
6
+ REM
7
+ REM Modifications :
8
+ REM
9
+ REM Description : Shows the open cursors and the maximum number of cursors
10
+
11
+ CREATE OR REPLACE PROCEDURE tp_open_cursors
12
+ AS
13
+
14
+ -- Variable Declaration
15
+
16
+ lv_highest sys .v $sesstat .value %TYPE;
17
+ lv_max sys .v $parameter .value %TYPE;
18
+ lv_percentage NUMBER ;
19
+
20
+ -- Create the cursors
21
+
22
+ CURSOR c_open_cursor IS
23
+ SELECT MAX (a .value ) AS highest_open_cursor, p .value AS max_open_cursor
24
+ FROM v$sesstat a, v$statname b, v$parameter p
25
+ WHERE a .statistic # = b.statistic#
26
+ AND b .name = ' opened cursors current' AND p .name = ' open_cursors'
27
+ GROUP BY p .value ;
28
+
29
+ -- Output the Information
30
+
31
+ BEGIN
32
+ DBMS_OUTPUT .PUT_LINE (CHR(10 )|| ' Open ' || CHR(9 ) || ' Max Cursors' );
33
+ DBMS_OUTPUT .PUT_LINE (' ==== ' || CHR(9 ) || ' ===========' );
34
+ OPEN c_open_cursor;
35
+ LOOP
36
+ FETCH c_open_cursor into lv_highest,lv_max;
37
+ EXIT WHEN c_open_cursor%NOTFOUND;
38
+ DBMS_OUTPUT .PUT_LINE (lv_highest|| CHR(9 )|| lv_max);
39
+ END LOOP;
40
+ CLOSE c_open_cursor;
41
+ lv_percentage := (lv_highest / lv_max * 100 );
42
+ DBMS_OUTPUT .PUT_LINE (CHR(10 ) || ' You are using ' || TRUNC(lv_percentage,2 ) || ' % of the open_cursors parameter' );
43
+ END tp_open_cursors;
44
+ /
You can’t perform that action at this time.
0 commit comments