title: pl/sql varray with a cursor
body: <p>Could someone tell me what is wrong with this code. My aim is to write a procedure which is passed an employee’s name, loads all the names and salaries from the employee table into a VARRAY, and then prints out the names and salaries on screen.</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE VARRAY_Q2 
  (
    PNAME IN VARCHAR2  
  , PSAL OUT NUMBER  
  ) AS 
  
  --declare and create cursor
  
  CURSOR emp_cur IS
  SELECT ename,sal
  FROM EMP;
  
    TYPE varray_emp IS VARRAY(14) OF emp_Cur%ROWTYPE;
  
    --Creating new instance of varray
    x_varray_emp varray_emp := varray_emp();
    v_counter NUMBER := 0;
  
  BEGIN
  
    x_varray_emp.EXTEND;
  
    FOR empRecs IN emp_Cur LOOP
  
    --Insert data into the varray
    x_varray_emp(v_counter) := empRecs;
  
    dbms_output.put_line(v_counter);
  
    v_counter := v_counter + 1;
    END LOOP;
  
    --Loop through the varray and print out all the elements
    FOR i IN x_varray_emp.FIRST .. x_varray_emp.LAST 
    LOOP
    dbms_output.put_line(x_varray_emp(i));    
    END LOOP;
  
  END;
  </code></pre>