Write a PL/SQL Cursor to display the employee details according to the department table department number. Every department details should be following conditions. i) If Employee HRA salary is basic*0.45. ii) If Employee DA salary is basic*0.35. iii) If Employee PF salary is basic*0.15.

0
Write a PL/SQL Cursor to display the employee details according to the department table department number. Every department details should be following conditions.
i)  If Employee HRA salary is basic*0.45.
ii) If Employee  DA salary is basic*0.35.
iii) If Employee PF salary is basic*0.15.

SQL>DECLARE
         cursor dc is
         select unique deptno
         from emp;
         cursor ec(pdno in emp.deptno%type)
         is
         select empno,ename,sal basic,sal*0.45 hra,
         sal*0.35 da,sal*0.15 pf,deptno
         from emp
         where deptno=pdno;
         vdno emp.deptno%type;
         i ec%rowtype;
         vgross number;

         BEGIN
         delete from emp_report;
         open dc;
         loop
             fetch dc into vdno;
            exit when dc%notfound;
             open ec(vdno);
                    loop
                    fetch ec into I;
                    exit when ec%notfound;
                    vgross:=i.basic+i.hra+i.da-i.pf;
                    insert into emp_report values(i.empno,i.ename,i.basic,i.hra,i.da,i.df,vgross,i.deptno);
                    end loop;
             if ec%rowcount>0 then
             insert into emp_report(ecode) values(null);
             end if;
             close ec;
         end loop;
         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