Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with "ORA-06511: PL/SQL: cursor already open"

427861Aug 17 2004 — edited Aug 31 2004
I've tried numerous variations on this piece of code and I always get the same result. I'm sure this is painfully obvious to an experienced PL/SQL person.

Any help will be appreciated!

Thank You!

1 DECLARE
2 CURSOR EMP_CURSOR IS SELECT last_name from employees;
3 current_last_name varchar2(25);
4 BEGIN
5 IF EMP_CURSOR%ISOPEN
6 THEN
7 dbms_output.put_line ('cursor is already open');
8 close EMP_CURSOR;
9 END IF;
10 dbms_output.put_line ('opening cursor');
11 OPEN EMP_CURSOR;
12 FOR item in EMP_CURSOR LOOP
13 FETCH EMP_CURSOR INTO current_last_name;
14 EXIT WHEN EMP_CURSOR%NOTFOUND;
15 dbms_output.put_line (item.last_name);
16 END LOOP;
17 CLOSE EMP_CURSOR;
18* END;
19 /
DECLARE
*
ERROR at line 1:
ORA-06511: PL/SQL: cursor already open
ORA-06512: at line 2
ORA-06512: at line 12
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2004
Added on Aug 17 2004
5 comments
2,858 views