oracle pl/sql DBMS_LOCK 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10870787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
oracle pl/sql DBMS_LOCK error
提问by user595234
In the Oracle PL/SQL, I want to test the sleep function. I am using hr schema. but it gives me error :
在Oracle PL/SQL中,我想测试sleep功能。我正在使用 hr 架构。但它给了我错误:
PLS-00201: identifier 'DBMS_LOCK' must be declared
code:
代码:
begin
DBMS_LOCK.Sleep( 60 );
end;
/
回答by archimede
You should grant executeon that package to your schema
您应该将对该包的执行授予您的架构
grant execute on <object> to <user>;
e.g.
例如
connect as sys
grant execute on SYS.DBMS_LOCK to someuser;
回答by chenrici
If you you don't have access to sys or your dba is unwilling to do
如果您无权访问 sys 或您的 dba 不愿意这样做
GRANT EXECUTE on SYS.DBMS_LOCK to you;
You can create a Java procedure in the database:
您可以在数据库中创建一个 Java 过程:
CREATE OR REPLACE PROCEDURE SLEEPIMPL (P_MILLI_SECONDS IN NUMBER)
AS LANGUAGE JAVA NAME 'java.lang.Thread.sleep(long)';
And create a function, which calls the java stored procedure
并创建一个函数,调用java存储过程
CREATE OR REPLACE FUNCTION sleep (
seconds IN NUMBER
) RETURN NUMBER
AS
BEGIN
SLEEPIMPL( seconds );
RETURN seconds;
END;
which after a
之后
GRANT EXECUTE ON sleep TO public;
you can call from a select
你可以从一个选择中调用
select sleep(6000) from dual