user508434
user508434

Reputation:

SQLDeveloper: execute current line without highlighting

In Toad one can easily execute current line without highlighting it. Let say, you have a worksheet like this:

select * from item -- cursor here


select * from product

When I click on CTRL+Enter I want only the line where the cursor is to be executed. In SQLDeveloper, if there is no second line, CTRL+Enter works as I want. Basically, I want to do the same as described here, but for some reason, I can't find the Tools -> Preferences -> Window Types -> SQL Window and check "AutoSelect statement" in the version of the SQLDeveloper I am using: 4.0.0.13, build Build MAIN: 13.80.

Seems like, this functionality is taken out in the 4.x of Oracle SQLDeveloper?

Upvotes: 14

Views: 21125

Answers (4)

Saurabh Singh
Saurabh Singh

Reputation: 1

I also ran into a similar situation where Ctrl+Enter shortcut stopped working for executing any statement and had to highlight the entire statement for executing it.

How it worked: (i) By removing/commenting out all the comments in the worksheet i.e. just have only the Sql statements in the worksheet, if at all you have put any statements/comments in the worksheet for your understanding, just disable those and then Ctrl+Enter starts working.

PS: I didn't do any other changes apart from this to make this shortcut work.

Cheers

Upvotes: 0

Rafal
Rafal

Reputation: 111

Actually the best option is mentioned here : http://forums.allroundautomations.com/ubb/ubbthreads.php?ubb=showflat&Number=46683

1) Press Ctrl-F8 when the cursor is on the statement. Now only the current statement is executed. You can assign a different key through the preferences (Tools > Preferences > Key Configuration > "SQL Window: Execute current statement").

2) Enable the "AutoSelect statement" preference (Tools > Preferences > SQL Window). Now the standard execute function will automatically select the current statement under the cursor and execute it. To execute multiple statements you now have to explicitly select them first in the editor, or use Ctrl-F8.

Upvotes: 11

Shankar
Shankar

Reputation: 191

If you have a block (anonymous or such) of code before your sql statement, make sure to end with forward slash, for the CTRL+enter to work.

CTRL+Enter on the select sysdate statement below works in second example below, but not on the first example.

Example 1:

begin
NULL;
end;

select sysdate from dual; -- press CTRL+Enter on this statement

Example 2:

begin
NULL;
end;
/

select sysdate from dual; -- press CTRL+Enter on this statement

Upvotes: 19

user508434
user508434

Reputation:

For those who also wonder about the same thing, here is what you gotta do. End each statement with ; and it works.

select * from item
;

select * from product;

Upvotes: 9

Related Questions