plsql cursor iterating problem -


I used the Oracle demo schema Scott to test some plsql I use (data will never change in that schema). I wrote the following program to get the employee number of each department. The problem is, there are only 4 departments but my program output 5 lines can not tell the reason for this, can anybody help? great thank you.

  Announce cursor staff (department_id number) Selection count from Scott.Empi (*) howmany where deptno = department_id; Employees_per_dept employee% rowtype; The cursor is selected from the department * Scott dept; A department department% line type; Start dbms_output.put_line ('------------------------------' ''); Open section; Exit loop when section% notfound; Moving departments into a department; Open staff (a_department.deptno); Bring employees to employees; Dbms_output.put_line (employees_per_dept.howmany); Closed employees; End loop; Closed department; Dbms_output.put_line ('----------------------------------' '); End; If you output deptno in dbms_output, you will see the reason. You must switch these two lines:  
 
Moving departments into a department; Exit when the department% notfound;

% NOTFOUND is meaningless before the initial FETCH; Your code was computing MPS in the last afternoon.


Comments

Popular posts from this blog

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -