PL/SQL Cursor to Find Total Salary in Department

PL/SQL Cursor to Find Total Salary in Department:


declare
dno number;
vdno number;
totsalary number;
cnt number;
cursor tot_sal(vdno number) is select * from emp where deptno=vdno;
begin
cnt:=0;
totsalary:=0;
vdno:=:vdno;
dbms_output.put_line('Department Number is: '||vdno);
for i in tot_sal(vdno)
loop
totsalary:=totsalary+i.sal;
end loop;
dbms_output.put_line('Total salary in department is: '||totsalary);
end;

OUTPUT:

Department Number is: 30
Total salary in department is: 9400



Leave a Reply

Your email address will not be published. Required fields are marked *

4 × four =