Monday, December 30, 2013

Oracle Cursor With Basic Loop.

Using oracle cursor with basic loop.

DECLARE
CURSOR C1 IS
SELECT EMPLOYEE_ID, LAST_NAME
FROM EMPLOYEES
WHERE DEPARTMENT_ID=90;

V_EMPID VARCHAR2(100);
V_NAME  VARCHAR2(300);

BEGIN

OPEN C1;

LOOP

FETCH C1 INTO V_EMPID, V_NAME;
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(V_EMPID ||' '||V_NAME);

END LOOP;

END;

No comments:

Post a Comment