简体   繁体   English

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

[英]DBMS_LOCK throwing error in procedure ie identifier must be declared

When I execute "dbms_lock.sleep", it runs successfully. 当我执行“ dbms_lock.sleep”时,它成功运行。 However, when I put the it in a procedure then it throws error like 'identifier 'DBMS_LOCK must be declared'' 但是,当我将其放在过程中时会引发类似``identifier'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;
/

The below is from dba_objects: 以下来自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

Privileges obtained through a role are not effective inside a PL/SQL block. 通过角色获得的特权在PL / SQL块内部无效。 The execute privilege on the package needs to be granted to the user directly, eg: 需要直接将包的execute特权授予用户,例如:

grant execute on dbms_lock to your_oracle_user;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM