User Tools

Site Tools


kurs:procedure_salary_diff
PROCEDURE SALARY_DIFF
   IS
cursor bonus_salary is
  SELECT
      first_name,
      last_name,
      salary
    FROM bonus
      order by salary desc;

v_first_name bonus.last_name%TYPE;      
v_last_name  bonus.last_name%TYPE;
v_salary     bonus.salary%TYPE;
v_diff       bonus.salary%TYPE;      
v_old        bonus.salary%TYPE;            

BEGIN
open bonus_salary;
   select max(salary) into v_old from bonus;
   loop
     fetch bonus_salary into v_first_name, v_last_name, v_salary;
     exit when bonus_salary%notfound;
     v_diff := v_salary - v_old;
     -- dbms_output.put_line(v_last_name||' '||v_salary||' '||v_diff);
     v_old := v_salary;
     update bonus set difference = v_diff where
       first_name = v_first_name and
       last_name  = v_last_name; 
     
   end loop;
close bonus_salary;
     
END; -- Procedure
kurs/procedure_salary_diff.txt · Last modified: 2014/09/10 21:22 (external edit)