Solved

select from the table v$sesstat in a stored procedure

Posted on 2004-04-30
3
1,062 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:tomerikv
3 Comments
 
LVL 23

Expert Comment

by:seazodiac
Comment Utility
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
 
LVL 3

Accepted Solution

by:
dbms_chu earned 95 total points
Comment Utility
Try logging in as sysdba then:

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

0
 
LVL 1

Author Comment

by:tomerikv
Comment Utility
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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to recover a database from a user managed backup

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now