Wednesday, January 19, 2011

Example of Cursor in PL/SQL


 (1) Write a PL/SQL block which display all employee name and salary using cursor.
declare
            ename emp.empname%type;
            sal emp.salary%type;
            cursor employee is select empname,salary from emp;
     begin
            open employee;
            loop
                    fetch employee into ename,sal;
                    exit when employee%notfound;
                    dbms_output.put_line(ename || sal);
            end loop;
            close employee;
    end;

No comments:

Post a Comment