简单的 Oracle 存储过程出现无效对象错误

发布于 2024-08-31 19:41:12 字数 1012 浏览 6 评论 0原文

我正在尝试编写一个简单的 Oracle 存储过程:

CREATE OR REPLACE PROCEDURE act.skeleton
IS
DECLARE
  v_rowCount NUMBER;
BEGIN
  SELECT COUNT(1) INTO v_rowCount FROM ex.emp;
  DBMS_OUTPUT.PUT_LINE(v_rowCount);
END;

但是,当我尝试 &通过在 PL/SQL Developer 命令窗口中发出 execute act.sculpture 来运行该过程,我收到以下错误消息:

ORA-06550: line 1, column 11:
PLS-00905: object ACT.SKELETON is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

我尝试在没有 create procedure 语句的情况下运行代码它运行成功并显示输出。我已经尝试了 CREATE OR REPLACE PROCEDURE IS & CREATE OR REPLACE PROCEDURE AS 选项,但我仍然遇到相同的错误。

我不确定当我尝试执行该过程时,这是否与该过程的授权或可见性有关,或者是什么导致 act.sculpture 对象无效。我研究了错误的含义&看起来它通常是指过程中的编译错误,但由于我可以在没有过程声明的情况下运行代码,我猜测声明部分是罪魁祸首。我只是不知道到底是什么原因造成的,我希望有人能够提供更多信息并为我指明正确的方向

谢谢,

Ashish

其他详细信息:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production

I am trying to write a simple Oracle Stored Procedure:

CREATE OR REPLACE PROCEDURE act.skeleton
IS
DECLARE
  v_rowCount NUMBER;
BEGIN
  SELECT COUNT(1) INTO v_rowCount FROM ex.emp;
  DBMS_OUTPUT.PUT_LINE(v_rowCount);
END;

However, when I try & run the procedure by issuing execute act.skeleton in PL/SQL Developer command window, I get the following error message:

ORA-06550: line 1, column 11:
PLS-00905: object ACT.SKELETON is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

I tried to just run the code without the create procedure statement & it runs successfully with the output being displayed. I have tried both CREATE OR REPLACE PROCEDURE IS & CREATE OR REPLACE PROCEDURE AS options but I still get the same error.

I am not sure if this has anything to do with authorization or visibility of the procedure when I try and execute it or what is causing the act.skeleton object to be invalid. I looked into what the error means & it seems it usually refers to compilation error in the procedure but since I can run the code sans the procedure declaration, I am guessing the declaration piece is the culprit. I just don't know enough to figure out what is causing this and I was hoping that someone will be able to shed some more light on it and point me in the right direction

Thanks,

Ashish

Other Details:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜巴黎 2024-09-07 19:41:12

不要在存储过程声明中使用 DECLARE 关键字。删除它,它应该可以编译。

Don't use the DECLARE keyword in a stored procedure declaration. Remove that and it should compile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文