Cursor FOR loop - Exercise

Contact Us or call 1-877-932-8228
Cursor FOR loop - Exercise

Cursor FOR loop

Duration: 5 to 10 minutes.
  1. Create a script that lists department names from the department table using a cursor FOR loop.

Solution:

Use-of-SQL-in-PLSQL/Solutions/departments_cursor_for_loop_solution.sql
begin

 FOR c IN (select department_name
           from departments 
           order by department_name)
 LOOP
        dbms_output.put_line(c.department_name);
 END LOOP;

end;
/

Code Explanation

Next