gpt4 book ai didi

sql - PLS-00201 : identifier 'NO_EMPLOYEES' must be declared

转载 作者:行者123 更新时间:2023-12-03 08:22:36 33 4
gpt4 key购买 nike

嗨,我需要帮助,因为我遇到了以下错误:
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;

最佳答案

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

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

关于sql - PLS-00201 : identifier 'NO_EMPLOYEES' must be declared,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23529386/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com