I am using IF condition in sql*plus but cannot access the variable of the outer loop in the inner loop. Here’s my statement:
DECLARE
LOOPSTART INT;
LOOPEND INT;
VALUE INT;
CURSOR EMPID IS (SELECT EMPNO FROM EMP);
BEGIN
SELECT EMPNO INTO LOOPSTART FROM emp WHERE ROWNUM <= 1;
SELECT MAX(EMPNO) INTO LOOPEND FROM EMP;
FOR COUNT IN LOOPSTART..LOOPEND LOOP
BEGIN
FOR EMPID1 IN EMPID LOOP
IF (EMPID1.EMPNO != COUNT) THEN
DBMS_OUTPUT.PUT_LINE(LOOPSTART);
exit;
END IF;
END LOOP;
END;
END LOOP;
END;
and this error came:
ORA-06550: line 13, column 22:
PLS-00204: function or pseudo-column ‘COUNT’ may be used inside a SQL statement only
ORA-06550: line 13, column 2:
PL/SQL: Statement ignored
- DECLARE
- LOOPSTART INT;
- LOOPEND INT;
Where am I getting wrong?
Rename the varialble count used to count_my or any thing else you like