 DECLARE
v_s_id enrollments.stu_id%TYPE:=:stu_id;
CURSOR s_class_cur IS
SELECT enrollment_date, class_id, status
FROM enrollments
WHERE stu_id=v_s_id
AND enrollment_date BETWEEN ADD_MONTHS(sysdate,-72) AND SYSDATE;
s_class_rec s_class_cur%rowtype;
BEGIN
DBMS_OUTPUT.PUT_LINE ('STUDENT '||v_s_id||' is enrolled in the following classes within the most recent 6 years:' );
open s_class_cur;
loop
fetch s_class_cur INTO s_class_rec; 
exit when s_class_cur%notfound;
DBMS_OUTPUT.PUT_LINE(s_class_rec.class_id||' with enrollment date '||s_class_rec.enrollment_date||' and with status '||s_class_rec.status);
END LOOP;
close s_class_cur;
END;