PLS-00201:必须声明标识符'NO_EMPLOYEES'

时间:2014-05-07 22:11:06

标签: sql database oracle plsql syntax-error

嗨我需要帮助,因为我正在处理以下错误: PLS-00201:必须声明标识符'NO_EMPLOYEES'

CREATE or replace PACKAGE police_employee_mgmt AS 
   no_employees NUMBER;
   FUNCTION insert_employee
   (emp_id NUMBER, emp_name VARCHAR2, emp_grade NUMBER, emp_password VARCHAR2, emp_username VARCHAR2)
RETURN NUMBER;
   PROCEDURE delete_employee(emp_id NUMBER);
   PROCEDURE change_employee_grade(emp_id NUMBER, emp_grade NUMBER);
END police_employee_mgmt;

然后创建一个函数来为变量赋值:

CREATE OR REPLACE FUNCTION number_of_employees
RETURN NUMBER IS
total_employees NUMBER;
BEGIN
    SELECT COUNT(*) 
    INTO total_employees 
    FROM pl_police_employee;
    RETURN(total_employees);
END;

然后......

BEGIN
no_employees := number_of_employees();
END;

1 个答案:

答案 0 :(得分:2)

如错误所述,您需要声明没有员工。我假设你的最后一个代码块在你声明它的包之外。我想你也可以使用匿名声明:

DECLARE
  num_employees NUMBER;
BEGIN
  num_employees := number_of_employees();
  ...
END