Hello,
I am wondering why I get following CURSOR violations on the simple code example below:
- three times “Cursor - Ensure that any local cursors you are referencing have actually been opened”
** (18,16)
** (20,13)
** (22,19) - once “Cursor - Confirm that the cursor you are referencing has been opened”
** (12,14)
{code}
CREATE OR REPLACE PACKAGE BODY PKG_TEST
AS
CURSOR cursor1
IS
SELECT 1 FROM DUAL;
PROCEDURE PROC_TEST
IS
val_i NUMBER (10);
BEGIN
IF NOT cursor1%ISOPEN
THEN
OPEN cursor1;
END IF;
LOOP
FETCH cursor1 INTO val_i;
IF cursor1%NOTFOUND
THEN
CLOSE cursor1;
EXIT;
END IF;
/* ... some further code ... */
END LOOP;
END PROC_TEST;
END PKG_TEST;
/
{code}
Can anybody help me figuring out this?
IMHO it is necessary to ask here if the cursor is already opened due to its declarations in package scope and the possible exception for opening an already open cursor.
For sure one can fix this situation if the cursor is moved to procedure scope but that is not possible because it is reused at another place (this short example just does not contain this).
I am using Toad 9.7.2.5 …
I very much appreciate your help, thank you.