DBMS_LOCK在过程中抛出错误,即必须声明标识符

时间:2018-02-20 10:23:40

标签: oracle plsql

当我执行“dbms_lock.sleep”时,它成功运行。但是,当我把它放在一个过程中然后抛出错误就像'标识符'DBMS_LOCK必须声明''

exec dbms_lock.sleep ( 5 ); -- this is working 

create procedure p1
...
dbms_lock.sleep ( 5 ); -- Error(264,2): PLS-00201: identifier 'DBMS_LOCK' must be declared
...
end;
/

以下内容来自dba_objects:

SYS     DBMS_LOCK   PACKAGE BODY
SYS     DBMS_LOCK   PACKAGE
PUBLIC  DBMS_LOCK   SYNONYM
SYS     DBMS_OUTPUT PACKAGE
PUBLIC  DBMS_OUTPUT SYNONYM
SYS     DBMS_OUTPUT PACKAGE BODY

1 个答案:

答案 0 :(得分:2)

通过角色获得的权限在PL / SQL块中无效。需要直接向用户授予对包的execute特权,例如:

grant execute on dbms_lock to your_oracle_user;