Wednesday, March 9, 2011

Varray with Cursor


DECLARE
   CURSOR c1
   IS
      SELECT   *
          FROM tempemp
      ORDER BY ID;

   TYPE abc IS VARRAY (100) OF VARCHAR2 (1000);

   sub   abc;
BEGIN
   sub := abc ();

   FOR i IN c1
   LOOP
      sub.EXTEND;
      sub (sub.COUNT) := i.ID || ' ' || i.emp_name;
      DBMS_OUTPUT.put_line (sub (sub.COUNT));
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);
END;

Output:


No comments:

Post a Comment