Hi friends
In the below block(forloop) i am not getting the countsal values but when i execute the query it gives the count.By this(COUNTSAL) the below if condition fails .i don't know why it fails.
But when i use with simple loop it gives the correct result.
FOR LOOP:
CL SCR;
SET SERVEROUTPUT ON;
DECLARE
CURSOR C1 IS SELECT EMPNO,ENAME,COUNT(SAL) COUNTSAL FROM EMP GROUP BY EMPNO,ENAME;
EMP_REC C1%ROWTYPE;
BEGIN
FOR IND IN C1
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(IND.EMPNO);
DBMS_OUTPUT.PUT_LINE('SALCOUNT :'||EMP_REC.COUNTSAL);
IF EMP_REC.COUNTSAL > 0 THEN
DBMS_OUTPUT.PUT_LINE('NAMES'||EMP_REC.ENAME);
END IF;
END LOOP;
END;
simple loop;(getting correct output)
CL SCR;
SET SERVEROUTPUT ON;
DECLARE
CURSOR C1
IS
SELECT EMPNO,ENAME,COUNT(SAL) COUNTSAL FROM EMP GROUP BY EMPNO,ENAME;
EMP_REC C1%ROWTYPE;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO EMP_REC;
EXIT WHEN C1%NOTFOUND;
IF EMP_REC.COUNTSAL > 0 THEN
DBMS_OUTPUT.PUT_LINE('NAMES :'||EMP_REC.ENAME);
END IF;
END LOOP;
END;
Please suggest me.