Question
Written Assignment-Printing Report from Table Points: 45 Set echo on SET SERVEROUT ON Set up a spool file to receive your output for submission. I
Written Assignment-Printing Report from Table Points: 45
Set echo on
SET SERVEROUT ON
Set up a spool file to receive your output for submission. I would suggest c:\CS4210\wa6spool.txt
DECLARE a record variable, a variable to keep track of a change in Department_ID, and two accumulators
Add procedures to the DECLARE block to print a Head of Form, subtotals, and a grand total
In the BEGIN block add a select statement to read all employee records from HR.EMPLOYEES where DEPARTMENT_ID < 50, and a LOOP
Add DBMS_OUTPUT.PUT lines to build up the output line one field at a time
Add a DBMS_OUTPUT.NEW_LINE at the end to print the finished line
After the LOOP be sure to print the final subtotal and the grand total
Add a EXCEPTION block to report when no data is found
Compile and run the procedure
Close the spool file
SQL> Declare 2 Cursor employees_cursor 3 t1 int 4 Is 5 select * from employees where DEPARTMENT_ID<20; 6 BEGIN 7 FOR T 8 IN employees_cursor 9 LOOP 10 dbms_output.put(t.employee_id); 11 dbms_output.put(t.first_name); 12 dbms_output.put(t.salary); 13 dbms_output.put_line(''); 14 end loop; 15 select sum(salary) into t1 from employees where department_id<10; 16 dbms_output.put_line('Total is '||t1); 17 exception 18 when no_data_found then 19 dbms_output.put_line('Sorry No data found'); 20 end; 21 / t1 int * ERROR at line 3: ORA-06550: line 3, column 1: PLS-00103: Encountered the symbol "T1" when expecting one of the following: ( ; is return
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started