Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

select from the table v$sesstat in a stored procedure

Posted on 2004-04-30
3
1,074 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
ID: 10965099
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
ID: 10965134
Try logging in as sysdba then:

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

0
 
LVL 1

Author Comment

by:tomerikv
ID: 10966696
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

856 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