Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Set echo on SET SERVEROUT ON Set up a spool file to receive your output for subm

ID: 3866165 • Letter: S

Question

Set echo on

SET SERVEROUT ON

Set up a spool file to receive your output for submission. I would suggest c:cs422awa6spool.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

Explanation / Answer

DECLARE
N NUMBER(5);
Department_id number(5);
t1 number(5);
t2 number(5);
begin
for T IN (select * from emp where deptno<20)
loop
dbms_output.put(t.empno);
dbms_output.put(t.ename);
dbms_output.put(t.sal);
dbms_output.put_line('');
end loop;
select sum(sal) into t1 from emp where deptno<10;
dbms_output.put_line('Total is '||t1);
exception
when no_data_found then
dbms_output.put_line('Sorry No data found');
end;
/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote