Skip to main content

Posts

Showing posts from December, 2012

Inroduction to ORACLE Cursor

/*Fetch Every Emloyee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;     CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP;   BEGIN   OPEN CR_EMP;   LOOP     FETCH CR_EMP INTO VEMPNO,VENAME,VSAL;   EXIT WHEN CR_EMP%NOTFOUND;     DBMS_OUTPUT.PUT_LINE('EMPLOYEE DETAILS');      DBMS_OUTPUT.PUT_LINE('----------------');     DBMS_OUTPUT.PUT_LINE('ID: '||VEMPNO);     DBMS_OUTPUT.PUT_LINE('NAME: '||VENAME);     DBMS_OUTPUT.PUT_LINE('BASIC: '||VSAL);     DBMS_OUTPUT.PUT_LINE('----------------');   END LOOP;   CLOSE CR_EMP; END; OR /*Fetch Every Emloyee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ /*WHILE LOOP*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;     CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP;   B