温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

存储过程访问其他用户的表的问题

发布时间:2020-08-07 14:39:29 来源:ITPUB博客 阅读:180 作者:zchbaby2000 栏目:关系型数据库

今天写了一个存储过程,需要通过dblink把其他用户下面的表的数据增量copy到目标表中,结果访问其他系统的表的时候,在存储过程中一直有问题,在Stack Overflow中找到了答案。


In stored procedures, functions, and definers-rights packages, roles (such as  SELECT_CATALOG_ROLE ) are disabled. Therefore,  such a PL/SQL program can only fetch metadata for objects in its own schema . If you want to write a PL/SQL program that fetches metadata for objects in a different schema (based on the invoker's possession of SELECT_CATALOG_ROLE ), you must make the program invokers-rights.

To do this, you must add  authid  to your procedure.

create procedure tests authid CURRENT_USER is
  l_foo clob;beginselectregexp_replace(
  dbms_metadata.get_ddl('USER', 'SCOTT', null) ||
  dbms_metadata.GET_GRANTED_DDL ('SYSTEM_GRANT', 'SCOTT') ||
  dbms_metadata.GET_GRANTED_DDL ('OBJECT_GRANT', 'SCOTT') ||
  dbms_metadata.GET_GRANTED_DDL ('ROLE_GRANT', 'SCOTT'),'"' || chr(10), '";' || chr(10)) into l_foo 
from dual;end;/SQL> EXEC tests 
PL/SQL procedure successfully completed


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI