CREATE OR REPLACE PROCEDURE EXAMPLE_PROC
IS
CURSOR EMP_CUR IS
SELECT *
FROM EMP;
EMP_REC EMP_CUR%ROWTYPE;
BEGIN
OPEN EMP_CUR;
LOOP
FETCH EMP_CUR INTO EMP_REC;
EXIT WHEN EMP_CUR%NOTFOUND ;
DBMS_OUTPUT.PUT_LINE(EMP_REC.ENAME);
END LOOP;
CLOSE EMP_CUR;
END;
COMMAND USED TO EXECUTE PROCEDURE :
EXEC EXAMPLE_PROC;
OUTPUT :
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
IS
CURSOR EMP_CUR IS
SELECT *
FROM EMP;
EMP_REC EMP_CUR%ROWTYPE;
BEGIN
OPEN EMP_CUR;
LOOP
FETCH EMP_CUR INTO EMP_REC;
EXIT WHEN EMP_CUR%NOTFOUND ;
DBMS_OUTPUT.PUT_LINE(EMP_REC.ENAME);
END LOOP;
CLOSE EMP_CUR;
END;
COMMAND USED TO EXECUTE PROCEDURE :
EXEC EXAMPLE_PROC;
OUTPUT :
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
No comments:
Post a Comment
Please Give Your Comments!!
Note: Only a member of this blog may post a comment.