Friday, 29 June 2012

How To Use Cursor In PL/SQL


set serveroutput on
declare
cursor c1 is
select employee_id,first_name,job_id,salary from employees;
a employees.employee_id%type;
b employees.first_name%type;
c employees.job_id%type;
d employees.salary%type;
begin
open c1;
if c1%isopen then
loop
fetch c1 into a,b,c,d;
dbms_output.put_line(a || b||  c|| d);
exit when c1%notfound ;
end loop;
else
dbms_output.put_line('cursor not open');
end if;
close c1;
end;
/



No comments:

Post a Comment