Getting error while Executing Package(执行包时出错)
问题描述
表格结构:
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;
这篇关于执行包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:执行包时出错
基础教程推荐
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
