Explicit Cursor in PL/SQL

SQL> set pagesize 200;
SQL> set serveroutput on;

******************************************
DECLARE
   CURSOR C1 IS SELECT ENAME,SAL FROM EMP;
   VENAME EMP.ENAME%TYPE;
   VSAL EMP.SAL%TYPE;
BEGIN
  OPEN C1;
LOOP
  FETCH C1 INTO VENAME,VSAL;
 EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(VENAME||' '||VSAL);
END LOOP;
   CLOSE C1; 
END;

*****************************************
Previous
Next Post »