I want to retrieve all the information about each department from the DEPARTMENT table and display the information on the screen.
Column name Data type C
Yes, a simple way to do that is to use a loop. But, you're looping through nothing (never fetch anything into those variables) and never exit the loop. Besides, what exactly are you committing?
Here's how you might have done it (based on Scott's DEPT
table which is similar to yours):
SQL> set serveroutput on
SQL> begin
2 for cur_r in (select deptno, dname, loc from dept) loop
3 dbms_output.put_line(cur_r.deptno ||' '|| cur_r.dname ||' '|| cur_r.loc);
4 end loop;
5 end;
6 /
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
PL/SQL procedure successfully completed.
SQL>