SQL> SET SERVEROUT OFF
SQL> BEGIN
2
3 INSERT INTO T_SESSION_STAT SELECT 1, NAME, VALUE
4 FROM V$SESSTAT A, V$STATNAME B
5 WHERE A.STATISTI = B.STATISTI
6 AND A.SID = (SELECT SID FROM V$MYSTAT WHERE ROWNUM = 1);
7
8 P_TEST;
9
10 INSERT INTO T_SESSION_STAT SELECT 2, NAME, VALUE
11 FROM V$SESSTAT A, V$STATNAME B
12 WHERE A.STATISTI = B.STATISTIC#
13 AND A.SID = (SELECT SID FROM V$MYSTAT WHERE ROWNUM = 1);
14
15 P_TEST_AUTO;
16
17 INSERT INTO T_SESSION_STAT SELECT 3, NAME, VALUE
18 FROM V$SESSTAT A, V$STATNAME B
19 WHERE A.STATISTIC# = B.STATISTIC#
20 AND A.SID = (SELECT SID FROM V$MYSTAT WHERE ROWNUM = 1);
21
22 FOR C IN
23 (
24 SELECT *
25 FROM
26 (
27 SELECT A.NAME, C.VALUE + A.VALUE - 2 * B.VALUE VALUE
28 FROM
29 T_SESSION_STAT A,
30 T_SESSION_STAT B,
31 T_SESSION_STAT C
32 WHERE A.NAME = B.NAME
33 AND A.NAME = C.NAME
34 AND A.ID = 1
35 AND B.ID = 2
36 AND C.ID = 3
37 )
38 WHERE ABS(VALUE) > 0
39 ) LOOP
40 DBMS_OUTPUT.PUT_LINE(RPAD(C.NAME, 50, ' ') || C.VALUE);
41 END LOOP;
42
43 END;
44 /
PL/SQL 过程已成功完成。
SQL> TRUNCATE TABLE T_SESSION_STAT;
--------------------next---------------------
阅读(293) | 评论(0) | 转发(0) |