oracle 存储过程错误 PLS-00201:必须声明标识符“UTL_HTTP”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26369834/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 00:38:28  来源:igfitidea点击:

Stored procedure error PLS-00201: identifier 'UTL_HTTP' must be declared

oraclestored-procedures

提问by Luis Garcia

I am trying to create a stored procedure that request some XML data from a service. I have found several examples on-line and all of them point to using this UTL_HTTP package. However, every time I tried to compile my store procedure with that I get the error:

我正在尝试创建一个从服务请求一些 XML 数据的存储过程。我在网上找到了几个例子,它们都指向使用这个 UTL_HTTP 包。但是,每次我尝试使用它编译存储过程时,都会收到错误消息:

PLS-00201: identifier 'UTL_HTTP' must be declared

Here is the basic skeleton of the code I want to use.

这是我要使用的代码的基本框架。

PROCEDURE GET_XML_DATA2 AS

BEGIN
   DECLARE
   v_soap_request    VARCHAR2(32767);
   v_soap_response   VARCHAR2(32767);

   v_http_request    UTL_HTTP.req; --Fails here
   v_http_response   UTL_HTTP.resp; -- Fails here too
   v_action          VARCHAR2(4000) := '';

BEGIN

    null;

END;

END GET_XML_DATA2;

It fails in the indicated lines and does not compile. I am using Oracle Express Edition and I have already tried to grant my user execute rights to that package. It did not work. What else can I look at? What else could be causing this? Thanks!

它在指示的行中失败并且无法编译。我正在使用 Oracle Express Edition,并且我已经尝试授予我的用户对该包的执行权限。这没用。我还能看什么?还有什么可能导致这种情况?谢谢!

回答by Simon

As you already figured out yourself, this seems to be a permission problem. Your user does somehow not have access to the UTL_HTTP package. Make sure your user has the EXECUTE permission on the package:

正如您自己已经发现的那样,这似乎是一个权限问题。您的用户不知何故无权访问 UTL_HTTP 包。确保您的用户对包具有 EXECUTE 权限:

GRANT EXECUTE ON SYS.UTL_HTTP TO my_user;

Note that you might have to do this as SYS.

请注意,您可能必须以 SYS 身份执行此操作。

Using SQL Developer (which I can recommend if you're doing PL/SQL development), see if you can then look at the package somehow. If that does not help, please post the permissions that your user currently has.

使用 SQL Developer(如果您正在进行 PL/SQL 开发,我可以推荐它),看看您是否可以以某种方式查看包。如果这没有帮助,请发布您的用户当前拥有的权限。