Using the COUNT built-in with local variable is misleading and in the most of time it is a coding error.
DECLARE v_empno emp.empno%TYPE; ... BEGIN -- Because the v_empno is NULL at this point, this COUNT always returns 0. SELECT COUNT(v_empno) INTO i FROM employee WHERE employee.deptno = v_deptno; END;
BEGIN SELECT COUNT(*) INTO i FROM employee WHERE employee.deptno = v_deptno; END;