Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Unanswered: How to convert cursor(SYS_REFCURSOR) to an associative array.

    Hi,

    I'm new for database collection side, So please suggest or direct me for Converting cursor(SYS_REFCURSOR) to an associative array.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Indexed arrays are easier to work with:
    Code:
    DECLARE
       Emp_Csr   SYS_REFCURSOR;
    
       TYPE Emp_Type IS TABLE OF Emp%ROWTYPE
          INDEX BY PLS_INTEGER;
    
       Emp_Arr   Emp_Type;
    BEGIN
       OPEN Emp_Csr FOR 'Select * From Emp';
    
       FETCH Emp_Csr BULK COLLECT INTO Emp_Arr;
    
       FOR I IN 1 .. Emp_Arr.COUNT
       LOOP
          DBMS_OUTPUT.Put_Line ('E,p#: '|| Emp_Arr ( I ).Empno
                             || ', Name: '|| Emp_Arr ( I ).Ename );
       END LOOP;
    END;
    /
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •