Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

"Run Statement" and anonymous PL/SQL blocks

user10393748Mar 25 2014 — edited Mar 25 2014

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.

This post has been answered by thatJeffSmith-Oracle on Mar 25 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 22 2014
Added on Mar 25 2014
2 comments
706 views