Currently, we can extract a procedure when selecting a set of PL/SQL statements, which is nice. But I'd also like to be able to extract expressions into functions, local variables, constants. The refactoring should obviously offer the target scope where that expression should be declared. An example:
BEGIN
dbms_output.put_line('Hello world');
END;
/
Now, when selecting the string literal 'Hello world', I would like to be offered to extract that as a function:
DECLARE
FUNCTION f RETURN VARCHAR2 IS
BEGIN
RETURN 'Hello world';
END f;
BEGIN
dbms_output.put_line(f);
END;
/
Or a local variable / constant:
DECLARE
s VARCHAR2(20) := 'Hello world';
BEGIN
dbms_output.put_line(s);
END;
/
Of course, real world expressions can be much more complex than what I've shown so the refactoring should figure out all the dependencies / parameters and whether the refactoring is possible at all. If it is not possible, it should not be offered.