A loop must be defined to fetch multiple rows from an explicit cursor. It will fetch one row from the active cursor set on each iteration of the loop, as shown in the following code:
Declare
v_emp_code
t_employees.emp_code%TYPE;
v_emp_name t_employees.emp_name%TYPE;
v_emp_salary
t_employees.emp_salary%TWE:
v_increment number (10.2);
Cursor emp_cursor IS
Select emp_code, emp_name,
emp_salary from t_employees:
Begin
Open emp_cursor;
LOOP FETCH emp_cursor into v_emp_code,
v_emp_name, v_emp_salary:
EXIT WHEN emp_cursoMBOutOuNT > 10 or
emp_cursor%NOTPOuND or emp_cursor%NOTFOuND IS NULL;
V_increment := v_emp_salary • 0.20 DBMS_OUTPUT.
PUTLINE(v_emp_code II' 'Ilv_emp_name It " II v_increment);
END LOOP;
CLOSE emp_cursor;
END;