Write a PL/SQL Cursor to display the employee details according to the department table department number. Every department details should be separate with ‘--------------’.

1
Write a PL/SQL Cursor to display the employee details according to the department table department number. Every department details should be separate with ‘--------------’.

SQL>declare
          Cursor dc is
          select deptno
          from dept;
          cursor ec(pdno in dept.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 dept.deptno%type;
          i ec%rowtype;
          vgross number;
          begin
          open dc;
          loop
          fetch dc into vdno;
          exit when dc%notfound;
          vgross:=i.basic+i.hra+i.da-i.pf;
          display(i.empno||’ ‘||rpad(i.ename,8)||’ ‘||rpad(i.basic,5)||’ ‘||rpad(i.hra,5)||’ ‘||rpad(i.da,5)||’ ‘||rpad(i.pf,5)|| ‘ ‘||rpad(vgross,5)||’ ‘||i.deptno);
          end loop;
          if ec%rowcount>0 then
          display(‘------------------------------------------------‘);
          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.

1 comment:

  1. Thank you sir,
    This information is use full for me.

    ReplyDelete

Recent Posts