Granting SELECT on dictionary views ... (?)
XenofonMar 29 2010 — edited Mar 29 2010Hi there,
please try to find out, what I am doing wrong below:
1. I connect as sys:
connect sys as sysdba
2. Create a role. Just to point out the problem, it will have just CREATE SESSION, CREATE PROCEDURE
create role tr not identified;
grant create session to tr;
grant create procedure to tr;
3. Now the problem: I want the role (users with that role) to have SELECT privilege, just on one dict-view, that is v$session:
My first attempt is denied:
grant select on v$session to tr;
grant select on v$session to tr
*
FEHLER in Zeile 1:
ORA-02030: can only select from fixed tables/views
Now this in itself is wierd. I read v$-objects are synonyms to v_$-objects. Is that right? What is the problem here? See, what happens next...
4. grant select on v_$session to tr;
That works!
5. create user tu identified by tu;
grant tr to tu;
That works!
6. Now connect as tu/tu
sql*plus Test: select count(*) from v$session;
COUNT(*)
----------
46
works!
7. Now: create a simple stored function to perform the same as my query:
create or replace function testf
return number
is
res number;
begin
select count(*) into res from v$session;
return res;
end;
/
This is refused with ORA-00942: Table or view does not exist !!!
Simple query on v$session works, but its usage inside a stored function is not allowed??? Please explain!!!
Pointing out to the explanation in the documentation (just one link) would suffice. I just have not found an explanation for this behaviour!
Many thanks in advance!
Xenofon