oracle - Wierd PL SQL invalid cursor -


when running following code ora-01001: invalid cursor not sure whats going on, converted procedure , started happening;

create or replace procedure p_student_from_class_list (p_stu_id in number)  --declaring variable --     v_date date;       --creating cursor find data using p_stu_id paramenter--     cursor enrollments_cursor         select enrollment_date, stu_id, class_id, status         enrollments          stu_id = p_stu_id;   begin     /*changing date code looks classes student      entered in bind variable above last 10 years*/     v_date := add_months(sysdate, -120);     v_enrollment_record in enrollments_cursor     loop  --displays student's enrollment date, class id , current status each    class >they taken in last 10 years,from value entered in bind    variable--         if v_enrollment_record.enrollment_date          between v_date , sysdate             dbms_output.put_line('enrollment date: '             ||v_enrollment_record.enrollment_date             ||' class id: '||v_enrollment_record.class_id             ||' status: '||v_enrollment_record.status);         end if;     end loop;     --closing cursor --     close enrollments_cursor;      --application express processes statement--     commit;      --telling application express procedure has finished-- end p_student_from_class_list;    --anonymous block run procedure--  begin     p_student_from_class_list(--student id--); end; 

as said code working when got in procedure reason creating procedure gives error. have been racking brain trying work out.

you don't need manual close cursor use for <record> in <cursor> loop. need close cursor manually opened (and fetched).

just remove line:

    close enrollments_cursor; 

compare documentation for loop , open-fetch-close pattern.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -