

CREATE OR REPLACE PROCEDURE looping_example
IS
   cursor emp_cur is
        select ename
        from emp;
   loop_counter   NUMBER := 0;
   ename   varchar2(10);
   
BEGIN
   open emp_cur;

   fetch emp_cur into ename;

   while emp_cur%FOUND
   LOOP
      loop_counter := loop_counter + 1;
      DBMS_OUTPUT.put_line 
          ('Record ' || loop_counter || ' is Employee ' || ename );
      fetch emp_cur into ename;
   END LOOP;

   DBMS_OUTPUT.put_line ('Procedure Looping Example is done');
   
   close emp_cur;
   
END;
/

