title: Pl/SQL Looping through the values of a cursor
body: <pre><code>CREATE OR REPLACE Function TotalIncome
     ( name_in IN varchar2 )
     RETURN varchar2
  IS
     total_val number(6);
  
     cursor c1 is
       select monthly_income
       from employees
       where name = name_in;
  
  BEGIN
  
     total_val := 0;
  
     FOR employee_rec in c1
     LOOP
        total_val := total_val + employee_rec.monthly_income;
     END LOOP;
  
     RETURN total_val;
  
  END;
  </code></pre>
  
  <p>In this example, I am being told that that we are looping through the values of but what I dont understand is if we are looping through the values why is <code>employee_rec.monthly_income</code> necessary ? Also, when I do a <code>FETCH</code> on <code>employee_rec</code> I seem to be getting an error so I guess they are different from each other.</p>