Write a PL/SQL Cursor to display Employee number, Employee name, Salary, Basic HRA, DA, PF, Gross Salary and Department of employees and display the number of employees are eligible for the PF. (Hint: Those Employees having a salary above 4000 is eligible for the PF.).

0
Write a PL/SQL Cursor to display Employee number, Employee name, Salary, Basic HRA, DA, PF, Gross Salary and Department of employees and display the number of employees are eligible for the PF. (Hint: Those Employees having a salary above 4000 is eligible for the PF.).  

SQL>DECLARE
    cursor cpf is
  select empno,ename,sal basic,sal*0.45 hra,sal*0.35 da,sal*0.15 pf,deptno
    from emp
    where  sal>4000;
    i cpf%rowtype;
    vgross number;

    BEGIN
    open cpf;
    loop
    if cpf%found then
       vgross:=i.basic+i.hra+i.da-i.pf;
    display(i.empno||’ ‘||rpad(i.ename,8)||’ ‘||rpad(i.basic,6)||’ ‘||rpad(i.hra,5)|| ‘ ‘||rpad(i.da,5)||’ ‘||rpad(i.pf,5)||’ ‘||rpad(vgross,5)||’ ‘||i.deptno);
                      else
             exit;
             end if;
             end loop;

         display(‘No of emps eligible for pf is’||cpf%rowcount);
         close cpf;
         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