1.
declare
cursor cur_emp is select * from employee1;
emp_rec employee1 %rowtype;
begin
open cur_emp;
if cur_emp %isopen then
loop
fetch cur_emp into emp_rec;
exit when cur_emp %notfound;
dbms_output.put_line(emp_rec.emp_id||' '||emp_rec.emp_name||' '
||emp_rec.DEP_NAME);
end loop;
close cur_emp;
else
dbms_output.put_line('Cursor is closed ');
end if;
end;
=================================================================================
=======
2. DECLARE
CURSOR CUR_EMP(E_ID EMPLOYEE1.EMP_ID %TYPE)IS SELECT * FROM EMPLOYEE1 WHERE
EMP_ID=E_ID;
E_ID EMPLOYEE1.EMP_ID%TYPE:=&E_ID;
emp_rec employee1 %rowtype;
BEGIN
open cur_emp(e_id);
if cur_emp %isopen then
loop
fetch cur_emp into emp_rec;
exit when cur_emp %notfound;
update employee1 set salary =salary+(salary*0.5)WHERE EMP_ID=E_ID;
dbms_output.put_line('Salary Updated');
end loop;
close cur_emp;
else
dbms_output.put_line('Cursor is closed ');
end if;
end;
===================
3. DECLARE
CURSOR CUR_EMP(l_lt EMPLOYEE1.salary %TYPE,u_lt EMPLOYEE1.salary %TYPE)IS
SELECT * FROM EMPLOYEE1 WHERE salary between l_lt and u_lt;
l_lt EMPLOYEE1.salary %TYPE:=&l_lt;
u_lt EMPLOYEE1.salary %TYPE
=======================================================================
:=&u_lt;
BEGIN
for emp_rec in cur_emp(l_lt,u_lt)
loop
dbms_output.put_line(emp_rec.emp_name||' '||emp_rec.salary);
end loop;
end;