I often use control-enter to run the statement that the cursor is currently over. Normally this works fine. But it gets a little screwy once I add an anonymous PL/SQL block to the worksheet. As long as the anonymous block is the last thing on the worksheet, I can "run statement" as usual. But if I add a SQL query after an anonymous block and try to run statement, rather than running just the query, SQL Developer seemingly tries to compile everything from the beginning of the first anonymous block up to the current statement as one block.
For example, if I have a worksheet like the following:
SELECT 1 FROM DUAL; --run statement on this line works as expected, running just this query BEGIN --run statement anywhere within this block works as expected, running just this block DBMS_OUTPUT.PUT_LINE('X'); END; SELECT 1 FROM DUAL; --run statement on this line goes back to the "BEGIN" on line 3 and gives a compilation error
This is a major annoyance for me, as I often have a mix of SQL and anonymous blocks on a worksheet. I know that I can highlight just the code that I want, and run statement this way, but I would prefer not having to do this. I expected SQL Developer would be smart enough to know where each block begins/ends and realize my current statement is not part of the block above it. Is there a setting that can change this behavior? Or is this the way it is intended to work?
Either way, thanks for the great tool.
Add a '/' on line 5 and bump line 5 down to line 6
Awesome. Thank you!