执行程序包时出错 [英] Getting error while Executing Package

查看:146
本文介绍了执行程序包时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表结构:

Name       Null Type         
---------- ---- ------------ 
DPT_NO          NUMBER       
SALARY          NUMBER(10)   
PERIOD          VARCHAR2(10) 
START_DATE      DATE         
END_DATE        DATE     

包装:

CREATE OR REPLACE package body salary_sal AS
   PROCEDURE find_sal(c_dpt_no salary.dpt_no%TYPE) IS
   c_sal salary.salary%TYPE;
   BEGIN
      SELECT salary INTO c_sal
      FROM salary
      WHERE c_dpt_no= 108;
      dbms_output.put_line('Salary: '|| c_sal);
   END find_sal;
END salary_sal;

在执行上述操作时出现以下错误

while executing above I'm getting following error

Error: PL/SQL: Compilation unit analysis terminated
Error(1,14): PLS-00201: identifier 'SALARY_SAL' must be declared
Error(1,14): PLS-00304: cannot compile body of 'SALARY_SAL' without its specification.

推荐答案

您缺少包的声明.想法是将包的声明(如果需要的话,称为标头")分开,以便其他包/过程/函数可以从主体(实现)中对它进行编译.

You're missing the declaration of the package. The idea is to separate the declaration of the package ("the header", if you will), so other packages/procedures/functions can compile against it from the body (the implementation).

在您的情况下,您将需要以下内容:

In your case, you'd need something like:

CREATE OR REPLACE package salary_sal AS
   PROCEDURE find_sal(c_dpt_no salary.dpt_no%TYPE);
END salary_sal;

现在,一旦声明了包,就可以创建它的主体:

Now, once the package is declared, you can create its body:

CREATE OR REPLACE package body salary_sal AS
   PROCEDURE find_sal(c_dpt_no salary.dpt_no%TYPE) IS
   c_sal salary.salary%TYPE;
   BEGIN
      SELECT salary INTO c_sal
      FROM salary
      WHERE c_dpt_no= 108;
      dbms_output.put_line('Salary: '|| c_sal);
   END find_sal;
END salary_sal;

这篇关于执行程序包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆