今天写了一个存储过程,需要通过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 ofSELECT_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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。