Home » SQL & PL/SQL » SQL & PL/SQL » Can't close an open cursor
Can't close an open cursor [message #41809] Mon, 03 February 2003 21:46 Go to next message
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 Go to previous messageGo to next message
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
Re: Can't close an open cursor [message #41895 is a reply to message #41809] Sat, 08 February 2003 02:48 Go to previous message
SS
Messages: 46
Registered: November 2001
Member
If u r using for loop to use cursor..
its a implicit open,fetch,close loop...
u dont have to explicitly open,close the cursor
Previous Topic: Re: ORA-17008 "Closed Connection "
Next Topic: HELP ON NESTED TABLES
Goto Forum:
  


Current Time: Thu Jan 01 06:34:26 CST 2026