select from V$SESSION in function: ORA-00942: table or view does not exist
565983Mar 21 2007 — edited Mar 21 2007Hi all,
I want to write a package function that returns the number of active sessions, I try with the code below:
FUNCTION clientSessionCount RETURN NUMBER AS
retValue NUMBER;
BEGIN
SELECT COUNT(*) INTO retValue FROM V$SESSION
WHERE UPPER(PROGRAM) NOT LIKE 'ORACLE.EXE%';
RETURN retValue;
END clientSessionCount;
The result of compiling is: ORA-00942: table or view does not exist
But the query SELECT COUNT(*) FROM V$SESSION executed with the same user that owns the package works without errors.
What is my mistake?
Thanks and regards.
Maurizio