title: Oracle: How to populate/insert row to a Ref Cursor?
body: <p>Really need help regarding Ref Cursor. I have a Stored Procedure GET_PERSONROLES that have parameter type ref cursor. I just wanted to pupulate this ref cursor manually like inserting a row to the refcursor. 
  Can I insert a row into a refcursor though a loop?
  Thank you in advance.</p>
  
  <p>The procedure depends on this publicly declared type:</p>
  
  <pre><code>create or replace package types 
  as 
      type cursorTypePersonRole is ref cursor; 
  end;
  </code></pre>
  
  <p>Here is my pseudo-codeL</p>
  
  <pre><code>create or replace PROCEDURE GET_PERSONROLES
  ( 
    P_CURSOR IN OUT types.cursorTypePersonRole
  ) AS
    REFCUR SYS_REFCURSOR; 
    TYPE REFTABLETYPE IS RECORD (
      IS_MANAGER_LEVEL1 VARCHAR2(1),
      IS_MANAGER_LEVEL2 VARCHAR2(1)
    );
    TYPE TABLETYPE IS TABLE OF REFTABLETYPE;
    PERSONROLES_TABLETYPE TABLETYPE; 
  BEGIN
    --calls another stored proc to populate REFCUR with data without problem
    MY_STOREDPROC('12345', REFCUR);
    LOOP
      FETCH REFCUR BULK COLLECT INTO PERSONROLES_TABLETYPE;
      EXIT WHEN PERSONROLES_TABLETYPE.COUNT = 0;
      FOR indx IN 1 .. PERSONROLES_TABLETYPE.COUNT 
      LOOP
         -- I'm able to query perfectly the values of IS_MANAGER_LEVEL1 and IS_MANAGER_LEVEL 2
         -- I'm aware that the below codes are wrong
         -- However this means I wanted to insert these values to a row of the cursor if possible
         -- Do some logic to know what data will be assigned in the row.
         if PERSONROLES_TABLETYPE(indx).IS_MANAGER_LEVEL1 = 'Y' then
             P_CURSOR := &lt;DO SOME LOGIC AND ASSIGN THE VALUE TO THE ROW&gt;
         end if;
         if PERSONROLES_TABLETYPE(indx).IS_MANAGER_LEVEL2 = 'Y' then
             P_CURSOR := &lt;DO SOME LOGIC AND ASSIGN THE VALUE TO THE ROW&gt;
         end if;
      END LOOP;
    END LOOP;     
    CLOSE REFCUR;
  END GET_PERSONROLES;
  </code></pre>