select from the table v$sesstat in a stored procedure

Hi!

I want to make a stored procedure that select values from the table v$sesstat.

I'm logged into sqlplus as System.

The problem is that i get the error:
_________________________________________________

Errors for PROCEDURE SP_MEMORY2:

LINE/COL ERROR
-------- -------------------------------------------------------------
12/2     PL/SQL: SQL Statement ignored
13/7     PL/SQL: ORA-00942: table or view does not exist

___________________________________________________

this is the procedure I try to use:
____________________________________

create or replace procedure sp_memory2
as

      memsum number(12) := 0;
      thetime date;
      
      
      
begin

      thetime := sysdate;
      select sum(value) into memsum
      from v$sesstat;
                  
      dbms_output.put_line('The size is: ' || memsum || ' and the date and time is: ' || thetime);
      
end;
/
__________________________________

Can anyone tell me why this doesn't work and what I need to do to get to use this table in a stored procedure?

Greetings,

Tom-Erik
LVL 1
tomerikvAsked:
Who is Participating?
 
dbms_chuConnect With a Mentor Commented:
Try logging in as sysdba then:

sql> grant select on sys.v_$sesstat to system;

0
 
seazodiacCommented:
Can anyone tell me why this doesn't work and what I need to do to get to use this table in a stored procedure?

1. because system account does not have access to this view v$sesstat;

2. log in as SYSDBA,

SQL>grant select on v$sesstat to system;


then try your procs
0
 
tomerikvAuthor Commented:
Hi!

The anwer from seazodiac gave an error because of the lack of the underscore before $, but thanks to both of you!

: )

greetings,

Tom-Erik




0
All Courses

From novice to tech pro — start learning today.