我想编写一个过程或函数,它接受具有员工ID的游标并通过它循环。如果员工ID在薪水表中有任何薪水,则应该返回0,否则为薪水。最后,输出将作为数字或光标发送。有可能吗?
答案 0 :(得分:0)
DECLARE
salary_check INTEGER;
CURSOR c1
IS
SELECT employee_id FROM employee_table;
BEGIN
FOR emp_rec in c1
LOOP
BEGIN
SELECT salary
INTO salary_check
WHERE employee_id = emp_rec.employee_id; --or however you link salary to emp_id
EXCEPTION WHEN NO_DATA_FOUND
salary_check := 0;
END;
--do something with the employee salary before looping to the next employee
END LOOP;
END;
这应该是你会使用的骨头,因为你的细节很少,所以无法帮助你解决任何问题。