Oracle授予包执行权限后仍报PLS-00201错误排查
问题排查与解决方法
检查权限对象名的拼写一致性
你提到在db_tab_priv中确认CUST_DEV拥有CUST_DS.CUST_CTRL的权限,但代码调用的是CUST_DS.CUST_CTL.proc()——注意包名存在拼写差异(CUST_CTRLvsCUST_CTL),这是典型笔误,会导致授权对象与调用对象不匹配。
解决:执行正确的授权语句:grant execute on CUST_DS.CUST_CTL to CUST_DEV with grant option;执行后再次查询
db_tab_priv,确认权限对应到正确的包名CUST_CTL。确认被调用包的有效性
如果CUST_DS.CUST_CTL包本身处于无效状态,即便授权正确,调用方也无法识别其中的存储过程。执行以下语句检查包状态:select status from all_objects where owner = 'CUST_DS' and object_name = 'CUST_CTL' and object_type = 'PACKAGE'; select status from all_objects where owner = 'CUST_DS' and object_name = 'CUST_CTL' and object_type = 'PACKAGE BODY';若状态为
INVALID,先重新编译该包:alter package CUST_DS.CUST_CTL compile; alter package CUST_DS.CUST_CTL compile body;检查存储过程的可见性
确保proc()是CUST_DS.CUST_CTL的公有存储过程——必须在包规范(PACKAGE)部分声明,而非仅在包体(PACKAGE BODY)中定义。私有过程无法被外部用户直接调用。
可通过以下语句验证:select object_name, procedure_name from all_procedures where owner = 'CUST_DS' and object_name = 'CUST_CTL' and procedure_name = 'PROC';若无返回结果,说明该过程为私有,需修改包规范添加声明,或调整调用逻辑。
确认权限为直接授予而非通过角色
存储过程/包中无法使用通过角色授予的权限,必须直接将execute权限授予CUST_DEV用户。执行以下语句确认权限来源:select grantee, owner, table_name, privilege from dba_tab_privs where grantee = 'CUST_DEV' and owner = 'CUST_DS' and table_name = 'CUST_CTL';若结果为空,说明权限是通过角色授予的,需重新直接授予用户。
内容的提问来源于stack exchange,提问作者Diana Oryol
相关产品推荐
相关产品推荐

