plsql - 如何在与另一个不同的架构中调用不同包中的过程
问题描述
我想在与当前运行的模式和包不同的一个包中调用一个模式中声明的过程
还有一个几乎相关的问题,但我的不同之处在于被调用的过程在另一个模式和包中,而不仅仅是另一个包。
declare
l_hub_msg varchar(1000);
l_query varchar(1000);
begin
-- Call a procedure in the same schema. Problem is not here
l_query := 'pkg_hub.loadFlatTable' ;
execute immediate 'l_query' into l_hub_msg;
if l_hub_msg is not null and length(l_hub_portfolio_msg) > 0 then
-- The following line gives me an PLS-00201: identifier 'PKG_EMAIL_PAGE.SENDMSG' must be declared
PKG_EMAIL_PAGE.SENDMSG('Message', 'FromUser@mycompany.com','ToUser@mycompany.com','ToUser@mycompany.com'
'Content',
'someuser@mycompany.com');
end if;
end;
将此过程视为在模式 SCHEMA1 下运行,而 PKG_EMAIL_PAGE 是存在于模式 SCHEMA2 下的包。
使用 SQL Developer 菜单选项,据说我将 PKG_EMAIL_PAGE.SENDMSG 的 EXECUTE 访问权限授予 SCHEMA2。也就是说,它说它成功了。
虽然我无法让它工作:
GRANT EXECUTE ON PKG_EMAIL_PAGE.SENDMSG to SC_REPORT_NEW;
因为它说
QL Error: ORA-04042: procedure, function, package, or package body does not exist
04042. 00000 - "procedure, function, package, or package body does not exist"
*Cause: Attempt to access a procedure, function, package, or package body
that does not exist.
*Action: Make sure the name is correct.
感谢您的阅读;樵夫
解决方案
GRANT 不是针对包中的单个方法,而是针对整个包,并且它们不是授予另一个包而是授予另一个用户。
schema2需要授予:
GRANT EXECUTE ON pkg_email_page TO schema1
然后schema1可以调用此过程,但需要在调用中指定架构:
BEGIN
schema2.pkg_email_page.sendmsg( ... );
END;
推荐阅读
- snowflake-cloud-data-platform - 连接 SnowSQL 时出错无法建立新连接:
- asp.net - 用于 asp dotnet api 的 Ubuntu 服务用户
- python - 有谁知道我可以如何提高我的 RNN 的准确性
- python - KeyError: color='variable' 使用绘图
- google-colaboratory - 是否可以更改 google colab notebook IP/位置?
- html - 点击任一卡片时,Accordion 会展开所有卡片
- python - FiPy 查看器对数轴缩放和纵横比
- javascript - 如何更改此已弃用的代码 document.write 以提高页面速度
- angular - 连接链接的mongodb问题
- node.js - IBM Watson Assistant:如何使 Db2 的查询结果可下载为 CSV 文件?