Get an error while running the package

Table Structure:

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

Package:

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;
Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 后端存储 » Get an error while running the package

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录