为什么所有人都加了800??
set serveroutput on
create or replace procedure addsalary
is
v_id empcopy.employee_id%type;
CURSOR emp_update_cursor
IS
SELECT employee_id,salary,hire_date
FROM empcopy ;
cursor emp_info
is
select employee_id
from empcopy;
BEGIN
open emp_info;
fetch emp_info into v_id;
FOR emp_record IN emp_update_cursor LOOP
IF emp_record.hire_date>=to_date('2005','yyyy') THEN
UPDATE empcopy SET salary=salary + 300 where v_id=emp_record.employee_id;
elsIF emp_record.hire_date>=to_date('2004','yyyy') THEN
UPDATE empcopy SET salary=salary + 400 where v_id=emp_record.employee_id;
else
UPDATE empcopy SET salary=salary + 500 where v_id=emp_record.employee_id;
fetch emp_info into v_id;
END IF;
END LOOP;
END;
set serveroutput on
declare
num1 number:=0;
num2 number:=0;
num3 number:=0;
begin
addsalary();
select count(*) into num1 from empcopy where salary<2000;
select count(*) into num2 from empcopy where salary>=2000 and salary<=5000;
select count(*) into num3 from empcopy where salary>5000;
dbms_output.put_line('目前收入在2000低于2000的员工有'||num1||'人,2000到5000之间有'||num2||'人,5000以上有'||num3||'人!');
end;
为什么所有人都加了800??