PLSQL_5_6_Practice.pdf - www.oracle.com/academy Database...

This preview shows page 1 - 3 out of 5 pages.

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Database Programming with PL/SQL 5-6: Using Multiple Cursors Practice Activities Vocabulary No new vocabulary for this lesson Try It / Solve It 1. Write and run a PL/SQL block which produces a listing of departments and their employees. Use the DEPARTMENTS and EMPLOYEES tables. In a cursor FOR loop, retrieve and display the department_id and department_name for each department, and display a second line containing '----------' as a separator. In a nested cursor FOR loop, retrieve and display the first_name, last_name, and salary of each employee in that department, followed by a blank line at the end of each department. Order the departments by department_id, and the employees in each department by last_name. You will need to declare two cursors, one to fetch and display the departments, the second to fetch and display the employees in that department, passing the department_id as a parameter. Your output should look something like this (only the first few departments are shown): 10 Administration ----------------------------- Jennifer Whalen 4400 20 Marketing ----------------------------- Pat Fay 6000 Michael Hartstein 13000 50 Shipping -----------------------------
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture