Executing current query when pressing CTRL+ENTER

costa_basil

Member²
Toad has a very useful feature and that is when I press CTRL+ENTER it executes the current query the caret is in. It detects the block that contains the caret by finding the first and the last empty line and then it executes that block. This way when I have multiple queries I don't have to select the query I want to run.

Is there such a feature in PL/SQL? If not can you please, please add it. It is very useful.

Thanks
 
You can also go to Tools -> Preferences, select Window Types - SQL Window and check the box next to "AutoSelect statement". When you press your execute shortcut (which can be set under Preferences, User Interface-Key Configuration, Session / Execute), PLD will automatically select and execute the statement around your current cursor position or the previous statement if your cursor is past the semicolon.

WARNING: If a BEGIN..END block is in your SQL Window, the entire script will execute, not the just the nearest single statement.
 
This sort of does what I want but one needs to add semicolon at the end of each query and also it is not possible to run a sub-query by itself which is what I actually needed to to. Example:

select *
from table1
where field1 in (
select anotherfield from table2
)

If I want to run just select anotherfield from table2 in toad I add blank lines and then press CTRL+ENTER.

This would not work in pl/sql developer.

Patrick: I was wondering if you have time to change your add-in to look at the blank lines as statement delimiters (make it perhaps configurable).
 
Last edited:
Just a thought, how about instead of adding the blank lines (one before and one after), which in this case would be

Home, Enter, Down, Enter, F8

you could do

Home, Shift, End, F8?
 
I see what you are saying but the keys you listed apply to an one line statement. That is rarely the case in reality.

In general if you want to work on a sub-query you can separate it with blank lines and then on sub-sequent runs you don't need to select it again to run it, you can simply press CTRL+ENTER. This is the advantage over selecting and running the query. But if you run it only once there is no advantage since you have to add and remove the blank lines.

 
Last edited:
Back
Top