title: Using cursor to find all employees who need to have their salary updated
body: <p>I have a table called employees.  I am trying to    create an anonymous PLSQL block, which outputs the last names, salary and hiredate of the employees in the employees table. If the employee hiredate is more than 5 years, then next to the employee record I should display the string: ‘Due for a 10% raise’    and calculate that raise and display it next to the record.<br>
  I need to use the current year (2016) to do the calcuations to determine that each employee need a raise. </p>
  
  <pre><code>set serveroutput on
  DECLARE 
    v_empno employees.employee_id%TYPE;
    v_lname employees.last_name%TYPE;
    v_salary employees.salary%TYPE;
    v_hiredate employees.hiredate%TYPE;
    v_newsalary number(8,2); 
    CURSOR c_emp IS 
      SELECT e1.employee_id, e1.last_name, e1.salary, e1.hiredate  
      FROM employees e1, 
          (SELECT employee_id, TRUNC(MONTHS_BETWEEN(sysdate, hiredate)/12) years_of_service 
            FROM employees
          ) e2 
      WHERE e1.employee_id =e2.employee_id and years_of_service &gt;5; 
    BEGIN
  
      OPEN c_emp; 
      LOOP
        FETCH c_emp  into v_empo, v_lname, v_salary, v_hiredate
        DBMS_OUTPUT.PUT_LINE( v_empno ||'  '||v_lname || ' ' || v_salary ||'  '||v_hiredate );  
      END LOOP; 
    END; 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8kirg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8kirg.png" alt="Table"></a></p>