Sunday, 14 February 2016

Print Update Employee Salary using PL/SQL BLOCK using Cursor

Print Update Employee Salary using PL/SQL BLOCK using Cursor

declare

cursor c1 is select empno,sal,deptno from emp where deptno=10;

csal emp.sal%type;
ceno emp.empno%type;
cdno emp.deptno%type;

begin
open c1;

dbms_output.put_line('Employeee Info');
dbms_output.put_line('==============');
dbms_output.put_line('EmpNo   EmpName  EmpSalary');
loop
fetch c1 into ceno,csal,cdno;

update emp set sal=sal+(csal*.10) where deptno=cdno;
exit when c1%notfound;
dbms_output.put_line(ceno||'     '||cdno||'     '||csal);

end loop;
close c1;
end;
/

No comments:

Post a Comment