Write a PL/SQL Cursor to Hike the employee salary as following conditions If Employee salary is 0 to 1000 hike 5%. If Employee salary is 1001 to 2000 hike 25%. Other then this two conditions hike 35% of the all employees. (Display the Employee name,hiked sal as a outpu).

0
Write a PL/SQL Cursor to Hike the employee salary as following conditions
  1. If Employee salary is 0 to 1000 hike 5%.
  2. If Employee salary is 1001 to 2000 hike 25%.
  3. Other then this two conditions hike 35% of the all employees. (Display the Employee name,hiked sal as a outpu).
SQL>declare
              cursor c1 is
              select empno,ename,sql
              from emp
              where deptno=20;
          vempno emp.empno%type;
          vename emp.ename%type;
          vsal emp.sal%type;
              begin
              open c1;
              loop
              fetch c1 into  vempno,vename,vsal;
              exit when c1%notfound;
                  if vsal between 0 and 1000 then
                  vsal:=vsal+vsal*0.15;
                  elsif vsal between 1001 and 2000 then
                  vsal:=vsal+vsal*0.25;
                  else
                  vsal:=vsal+vsal*0.35;
                  end if;
                  update emp set sal=vsal
                  where empno=vempno;
                  display(rpad(vename,8)||’ ‘||vsal);
                  end loop;
              close  c1;
              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