Oracle - 源没有可运行的目标

发布于 2024-12-03 06:33:08 字数 779 浏览 1 评论 0原文

我对 Oracle 完全陌生。

我正在尝试创建一个包,但它抛出一个错误: 源没有可运行的目标。

我想要做的是创建一个包并在包体中定义一些存储过程。

这是我的包定义的样子:

CREATE OR REPLACE 
PACKAGE PAY_ZONE_PKG AS
  TYPE CURSOR_TYPE IS REF CURSOR;

  PROCEDURE spGetZones(Zones_Cursor OUT CURSOR_TYPE);

END PAY_ZONE_PKG;

这是我的包主体的样子:

create or replace
PACKAGE BODY PAY_ZONE_PKG IS

PROCEDURE spGetZones(Zones_Cursor OUT CURSOR_TYPE) AS
  BEGIN
    OPEN Zones_Cursor FOR
      SELECT *
      FROM ESP.PAY_ZONE
      ORDER BY NAME ASC;
  EXCEPTION
     WHEN NO_DATA_FOUND
     THEN NULL;
  END spGetZones;

END PAY_ZONE_PKG;

当我尝试创建包主体时,它会抛出错误,指出

cannot compile body of 'PAY_ZONE_PKG' without its specification

我在这里缺少什么?

I am completely new to Oracle.

I am trying to create a package but it throws me an error:
Source does not have a runnable target.

What i want to do is create a package and define some stored procs in the package body.

This is how my package definition looks like:

CREATE OR REPLACE 
PACKAGE PAY_ZONE_PKG AS
  TYPE CURSOR_TYPE IS REF CURSOR;

  PROCEDURE spGetZones(Zones_Cursor OUT CURSOR_TYPE);

END PAY_ZONE_PKG;

This is how my package body looks like:

create or replace
PACKAGE BODY PAY_ZONE_PKG IS

PROCEDURE spGetZones(Zones_Cursor OUT CURSOR_TYPE) AS
  BEGIN
    OPEN Zones_Cursor FOR
      SELECT *
      FROM ESP.PAY_ZONE
      ORDER BY NAME ASC;
  EXCEPTION
     WHEN NO_DATA_FOUND
     THEN NULL;
  END spGetZones;

END PAY_ZONE_PKG;

When i tried to create package body, it throws the error saying

cannot compile body of 'PAY_ZONE_PKG' without its specification

What am i missing here?

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

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

发布评论

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

评论(2

相权↑美人 2024-12-10 06:33:08

无法在没有规范的情况下编译“PAY_ZONE_PKG”主体表示创建或替换包 PAY_ZONE_PKG 失败,或者在尝试编译包规范后被删除身体。

所以,问题不在于身体,而在于规格。

cannot compile body of 'PAY_ZONE_PKG' without its specification indicates that the create or replace package PAY_ZONE_PKG was either unsucessful, or that the package specification was deleted after it was tried to compile the body.

So, the problem is not with the body, but with the specification.

哎呦我呸! 2024-12-10 06:33:08

我无法重现这一点。

代码:

CREATE OR REPLACE 
PACKAGE PAY_ZONE_PKG AS
  TYPE CURSOR_TYPE IS REF CURSOR;

  PROCEDURE spGetZones(Zones_Cursor OUT CURSOR_TYPE);

END PAY_ZONE_PKG;

编译。

并且身体也创建成功了。

您是否尝试过独立创建它们?第一个规格,然后是主体。

I'm not able to reproduce that.

The code:

CREATE OR REPLACE 
PACKAGE PAY_ZONE_PKG AS
  TYPE CURSOR_TYPE IS REF CURSOR;

  PROCEDURE spGetZones(Zones_Cursor OUT CURSOR_TYPE);

END PAY_ZONE_PKG;

compiles.

And also the body is created successfully.

Have you tried to create them independently. First spec, and after, body.

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