If user A
creates a view and grants READ
on it to PUBLIC
.
SQL>create view A.a_public as select 3 id from dual;
View created.
SQL>select * from A.a_public;
ID
----------
3
SQL>grant read on A.a_public to public;
Grant succeeded.
Then user B
can create a stored procedure selecting from A
‘s view and successfully execute that stored procedure.
SQL>create or replace procedure B.b_public
2 as
3 num NUMBER;
4 begin
5 select id into num from A.a_public;
6 dbms_output.put_line('~' || num || '~');
7 end;
8 /
Procedure created.
SQL>show errors
No errors.
SQL>set serveroutput on
SQL>exec B.b_public();
~3~
PL/SQL procedure successfully completed.
SQL>
READ
of SYS.V_$RESTORE_POINT
has been granted to PUBLIC
.
For the stored procedure below, why does the compilation succeed, but the execution fail?
SQL>select count(*) from dba_tab_privs where table_name = 'V_$RESTORE_POINT' and grantor = 'SYS' and grantee = 'PUBLIC' and privilege = 'READ';
COUNT(*)
----------
1
SQL>create or replace procedure w_restore_point
2 as
3 num_scn NUMBER;
4 begin
5 select scn into num_scn from
6 SYS.v_$restore_point
7 where rownum = 1;
8 dbms_output.put_line(num_scn);
9 end;
10 /
Procedure created.
SQL>show errors
No errors.
SQL>set serveroutput on
SQL>exec w_restore_point();
BEGIN w_restore_point(); END;
*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SCHEMA_NAME.W_RESTORE_POINT", line 5
ORA-06512: at line 1
SQL>
Using Oracle 19c EE.