我写了一个没有for循环的代码,请为我提供解决方案,通过for循环更新它,创建或替换程序PR_UPDATETBEMP(COMM IN NUMBER)AS
begin
UPDATE XX_TBEMP
SET COMM=SAL*.05
WHERE SAL BETWEEN 80000 AND 99999;
end PR_UPDATETBEMP;
答案 0 :(得分:0)
create or replace PACKAGE XX_UPDATETBEMP AS
PROCEDURE XX_UPDATECOMM;
end XX_UPDATETBEMP;
create or replace PACKAGEBODY XX_UPDATETBEMP AS
PROCEDURE XX_UPDATECOMM IS
CURSOR C_TBEMP IS SELECT * FROM XX_TBEMP;
R_TBEMP C_TBEMP%ROWTYPE;
BEGIN
FOR SAL IN C_TBEMP
LOOP
UPDATE XX_TBEMP
SET COMM = sal * 0.2 where SAL BETWEEN 30000 AND 49999;
UPDATE XX_TBEMP
SET COMM = sal * 0.15 where SAL BETWEEN 50000 AND 79999;
UPDATE XX_TBEMP
SET COMM = sal * 0.1 where SAL BETWEEN 80000 and 99999;
END LOOP;
END XX_UPDATECOMM;
END XX_UPDATETBEMP;