Categories
Uncategorized

Cursor(cIA 6)

1. Using Cursors Write a program that gives all employees in department MCA and 15% pay increase. Display a message displaying how many Employees were awarded the increase.

declare
v_name employee.name%type;
vdname department.dname%type;
vsal employee.salary%type;
vdno employee.deptno%type;
count number;
cursor empcursor2 is select name,dname,salary,e.deptno from employee e,department where
e.deptno=department.deptno and dname=’Research’;
begin
open empcursor2;
loop
fetch empcursor2 into v_name,vdname,vsal,vdno;
exit when empcursor2%notfound;
update employee set salary=salary+salary*0.15 where deptno=vdno;
count:=empcursor2%rowcount;
end loop;
dbms_output.put_line(count ||’ Number of people have been awarded 15% increase in ‘|| vdname);
close empcursor2;
end;
/