title: Using For loop to retrieve multiple rows in Oracle procedure
body: <p>Im working on stored procedure where I need to retrieve a set of results and process each element individually and then return the entire result.(using 3 different tables)</p>
  
  <p>Im not too familiar with databases, but heres what I was able to come up with.. </p>
  
  <pre><code>create or replace procedure GET_EMP_RSLT
    IS
  
  CURSOR ecursor IS select emp_id from temp_employee where 'some condition';
  
  BEGIN
  
  FOR empidset in ecursor  
  
    LOOP
  
    Select * from 
  
      (select * from payroll_info where emp_id = empidset.emp_id) a
  
      left join 
  
      (select * from benefit_info where emp_id = empidset.emp_id) b 
       on a.emp_id = b.emp_id    
  
    END LOOP;
  
  END;
  </code></pre>
  
  <p>On execution, I get the following error.. </p>
  
  <pre><code>an INTO clause is expected in this SELECT statement : "Select * from"
  </code></pre>
  
  <p>can anyone please explain on how do I correct this error and get the required results? </p>
  
  <p>PS. Im using Oracle 9i &amp; TOAD 9</p>
  
  <p>Thanks,<br>
  Tom</p>