When working with PL/SQL, sometimes I'd like to extract a useful implicit cursor to a named cursor which is declared somewhere in the current scope. For example, starting with:
FOR r IN (SELECT 1 x FROM dual) LOOP
I'd like to be able to transform the above automatically to:
SET SERVEROUTPUT ON
CURSOR c IS (SELECT 1 x FROM dual);
FOR r IN c LOOP
There are several places where this cursor could be declared, including a new DECLARE .. BEGIN .. END block just for the cursor. The hard part here will be to find a user-friendly way to specify where the declaration should go (this would apply for several of the refactorings that I will request in the near future).