Consider the following.
declare
v_name person.name%TYPE;
v_surname person.surname%TYPE;
cursor department_cursor is
select * from department;
cursor person_cursor is
select * from person
where nvl(name, '') = nvl(v_name, '');
begin
open department_cursor;
open person_cursor;
for department_row in department_cursor loop
v_name := department_row.name;
v_surname := department_row.surname;
for person_row in person_cursor loop
DBMS_OUTPUT.PUT_LINE('I got here:'||person_row.p_id);
end loop;
end loop;
close person_cursor;
close department_cursor;
end;
/
Don't try to understand what it does. It's just a stripped/vandalized version of the actual code. The juice though remains. What I want to do, is have two cursors. The second cursor is dynamic and it depends on the rows that the first cursor returns.
The above results in ORA-06511: PL/SQL: cursor already open .