Toad World® Forums

Open CURSOR multiple times using REF CURSOR, why?

Is there any special reason, why REF CURSOR can be opened multiple times and normal cursors not (see example below)?

{code}
DECLARE
TYPE type_cur IS REF CURSOR;

cur1 type_cur;

CURSOR cur2
IS
SELECT ‘a’ AS surname FROM DUAL;
BEGIN
/* example 1 - open ref cursor twice */

OPEN cur1 FOR SELECT NULL AS city FROM DUAL;

OPEN cur1 FOR SELECT ‘Munich’ AS city FROM DUAL; /* <= no exception here */

/* example 2 - open noraml cursor twice */

OPEN cur2;

OPEN cur2; /* <= ORA-06511: PL/SQL: cursor already open */
END;
/
{code}

CodeXpert reports me “Cursor - Avoid opening cursors that are already open” for that. I am using Toad 9.7.2.5.

Can anyone tell me if the above described problem still occurs the newest version (11.0) by using the provided code example?

Thank you for your help …

Anyone?