因此,我正在尝试调用已完成的过程。该过程成功完成,但是,当我尝试插入值时,它告诉我参数数量不正确。
CREATE OR REPLACE PROCEDURE insert_employee
(
p_employeeid IN employees.employeeid%TYPE,
p_employeename IN employees.employeename%TYPE,
p_phone IN employees.phone%TYPE,
p_jobid IN employees.jobid%TYPE,
p_salary IN employees.salary%TYPE,
p_managerid IN employees.managerid%TYPE,
p_departmentid IN employees.departmentid%TYPE,
jobid_cnt OUT INTEGER,
deptid_cnt OUT INTEGER,
empid_cnt OUT INTEGER
)
AS
BEGIN
IF p_employeeid IS NULL OR
p_employeename IS NULL OR
p_jobid IS NULL OR
p_salary < 0
THEN
RAISE VALUE_ERROR;
END IF;
SELECT count(*)
INTO jobid_cnt
FROM employees e
WHERE e.jobid = p_jobid;
IF jobid_cnt = 0 THEN -- there's no such job in the table
RAISE VALUE_ERROR;
END IF;
SELECT count(*)
INTO deptid_cnt
FROM employees e
WHERE e.departmentid = p_departmentid;
IF deptid_cnt = 0 THEN -- there's no such department in the table
RAISE VALUE_ERROR;
END IF;
SELECT count(*)
INTO empid_cnt
FROM employees e
WHERE e.employeeid = p_employeeid;
IF deptid_cnt > 0 THEN -- employee already exists within table
RAISE_APPLICATION_ERROR(-20001, 'Employee already exists');
END IF;
COMMIT;
END;
/
CALL insert_employee(109, 'Jack', '416 123 4567', 'FI_ACCOUNT', 7890.00, 104, 30);
我希望OUT参数不同于IN参数,但是我可能错了。该错误变为“ PLS-00306:INSERT_EMPLOYEE的调用中参数的数量或类型错误”谢谢
答案 0 :(得分:4)
您需要声明out参数并执行过程
declare
jobid_cnt INTEGER;
deptid_cnt INTEGER ;
empid_cnt INTEGER;
begin
insert_employee(109, 'Jack', '416 123 4567', 'FI_ACCOUNT', 7890.00, 104, 30,jobid_cnt,deptid_cnt,empid_cnt);
dbms_output.put_line(jobid_cnt);
dbms_output.put_line(deptid_cnt);
dbms_output.put_line(empid_cnt);
Commit;
end;