存储过程中的两个 PUBLIC 视图 - 一个成功,一个错误?

问题描述 投票:0回答:1

如果用户

A
创建了一个视图并将其上的
READ
授予
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.

然后用户

B
可以从
A
的视图中选择创建一个存储过程并成功执行该存储过程。

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
SYS.V_$RESTORE_POINT
已授予
PUBLIC
下面的存储过程,为什么编译成功,但执行失败?

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>

使用 Oracle 19c EE。

oracle stored-procedures view roles privileges
1个回答
0
投票

看起来您必须向正在使用

select_catalog_role
procedure 授予
v_$restore_point
权限。

grant select_catalog_role to procedure B.b_public;
© www.soinside.com 2019 - 2024. All rights reserved.