Write a PL/SQL Cursor to Hike the commission with the following conditions. i.If commission is null value give the commission as 300. ii.If commission is 0 give the commission as 250. iii.Other then this two conditions hike the 35%. (Display the output as Employee name, Updated Commission.).

0
Write a PL/SQL Cursor to Hike the commission with the following conditions.
i.If commission is null value give the commission as 300.
ii.If commission is 0 give the commission as 250.
iii.Other then this two conditions hike the 35%. (Display the output as Employee name, Updated Commission.).


SQL>DECLARE
          cursor cc is
          select empno,ename,comm.
          from emp;
          i cc%rowtype;

          BEGIN
          open cc;
          loop
          fetch cc into I;
          exit when cc%notfound;

          if i.comm is null then
              i.comm:=300;
          elsif i.comm=0 then
              i.comm:=250;
          else
              i.comm:=i.comm+i.comm*0.35;
          end if;

          update emp set comm:=i.comm
          where empno:=i.empno;
          display(rpad(i.ename,8)||’ ‘||i.comm);
          end loop;
          close cc;
          end;

 Click here to go to Back page

About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts