| Can't close an open cursor [message #41809] |
Mon, 03 February 2003 21:46  |
Andrew Gray
Messages: 2 Registered: February 2003
|
Junior Member |
|
|
Hi,
Thanks for any help in advance.
I have a PL/SQL procedure that defines a cursor and a %ROWTYPE variable and tries to do the following in the BEGIN..END clause
1. open the cursor
2. for each in cursorname loop
3. fetch cursorname into %ROWTYPE variable
4. Basic UPDATE
5. end loop
6. close cursor
In one test execution I think it was stuck in an endless loop so I killed TOAD. When I opened TOAD again, altered the procedure to not loop endlessly and reran it TOAD gives me:
ORA-06511: PL/SQL: cursor already open
ORA-06512: at "ProcedureName", line xx
ORA-06512: at "ProcedureName", line yy
ORA-06512: at line aa
For the life of me I can't close/kill or otherwise tell toad to forget about this cursor. Does anyone know how I can close this cursor??
I have already searched on ORA-06511 and it seems to be regarding something else entirely.
Many thanks.
Regards,
Andrew
|
|
|
|
| Re: Can't close an open cursor [message #41820 is a reply to message #41809] |
Tue, 04 February 2003 04:28   |
Adrian Billington
Messages: 139 Registered: December 2002
|
Senior Member |
|
|
Andrew
You could look at DBMS_SESSION.SET_CLOSE_CACHED_OPEN_CURSORS(TRUE)...
And as a comment on your code, if ever you open a cursor, you should include an exception handler to close it in the event of an error (or you killing TOAD ;) ) use "IF curname%ISOPEN THEN CLOSE curname; END IF;"
Regards
Adrian
|
|
|
|
|
|