Sunday, 14 February 2016

Display empno, name, salary, job and deptno of employees using cursor & %rowtype

Display empno, name, salary, job and deptno of employees using cursor & %rowtype

DECLARE
CURSOR c1 IS SELECT EMPNO,ENAME,SAL,JOB,DEPTNO FROM EMP;
EMP_REC c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
 FETCH c1 INTO EMP_REC;
 EXIT WHEN c1%NOTFOUND;
 DBMS_OUTPUT.PUT_LINE(EMP_REC.EMPNO || ',' || EMP_REC.ENAME|| ',' || EMP_REC.SAL|| ',' || EMP_REC.JOB|| ',' || EMP_REC.DEPTNO);
END LOOP;
CLOSE c1;
END;
/

No comments:

Post a Comment