User Tools

Site Tools


kurs:p_bonus
PROCEDURE P_BONUS
   
   IS
cursor c_bonus is
SELECT is_emp_bonus.last_name, is_emp_bonus.salary,
       is_emp_bonus.bonus
  FROM is_emp_bonus
  order by is_emp_bonus.salary DESC
  for update of bonus;

  type bon_rec_record_type is record
  (last_name  is_emp_bonus.last_name%TYPE,
   salary     is_emp_bonus.salary%TYPE,
   bonus      is_emp_bonus.bonus%TYPE);
  
  bon_rec   bon_rec_record_type;
  v_bonus   number(30,2);
  
BEGIN
    for bon_rec in c_bonus
    loop
    v_bonus := 0.2;
    if bon_rec.salary>5000 then
      v_bonus := 0.05;
    end if;
    update is_emp_bonus
      set bonus = bon_rec.salary*v_bonus
      where current of c_bonus;
    end loop;

END; -- Procedure
kurs/p_bonus.txt · Last modified: 2014/09/10 21:22 (external edit)