Execute query without selecting entire query

cmatta

Member
Hi,

Is there a way to execute a query without selecting entire query ?

If I have multiple queries on my SQL window, can I be able to execute a query without selecting entire query. May be by placing cursor/control somewhere on a specific query. ?

Problem is - When we have huge queries(lots of lines), it is very difficult to select entire query every time and execute it.
So I am trying to find other alternatives.

Thanks
 
Or you can see (or change) what is defined for "SQL Window: Execute current statement" key binding at:
Tools \ Preferences \ User Interface \ Key Configuration

The "SQL Window: Execute current statement" is the last position on the key binding list there, so it should be easy to find.

If you switch the "AutoSelect statement" option, as Bernard S suggests, then the "SQL Window: Execute current statement" key binding will work the opposite way (which means executing the selected text or whole SQL window content, if nothing is selected).
 
Thank you for suggesting that pluggin. It solved the problem I was having where plsql developer would not AutoSelect if my script/sql file contained an anonymous block elsewhere in the same script.

For example, if my script contained this:

BEGIN
dbms_output.put_line('testing anonymous block with auto_select feature in plsql developer');
END;

SELECT 'Hello from dual' FROM dual;

SELECT 'Bye from dual' FROM dual;

Then, even with AutoSelect enabled, it would fail if my cursor is on either of the two select statements in the script.

But the pluggin works great. I mapped it to the f9 key (which is what I used in Toad to execute). The downside is that I have to remember to use f8 for compiling source code or anonymous blocks but the f9 to use the new plugin. It is a small grievance but would be nice if the default functionality for AutoSelect worked in plsql developer even when the script contains anonymous blocks.

Thanks again.
 
Last edited:
Benny said:
[...] the problem I was having where plsql developer would not AutoSelect if my script/sql file contained an anonymous block elsewhere in the same script.

For example, if my script contained this:

Code:
BEGIN
    dbms_output.put_line('testing anonymous block with auto_select feature in plsql developer');
END;

SELECT 'Hello from dual' FROM dual;

SELECT 'Bye from dual' FROM dual;

Then, even with AutoSelect enabled, it would fail if my cursor is on either of the two select statements in the script.
Your original problem might have come from the fact that your script was actually incorrect - it did not contain correct separators.
As with Oracle SQL*Plus (with default settings), the PL/SQL Developer uses semicolon (";") to indicate end of a SQL query/command, but as the semicolon is used within PL/SQL blocks, to separate instructions, it can't be used to indicate end of a whole PL/SQL blocks, so for those, the backslash character is used ("/").
You do not have the backslash character at the end of your (anonymous) PL/SQL block, so the PL/SQL does not know that it ends just after "END;", so assumes that the next 2 select statements are part of it. Just as Oracle's SQL*Plus would.

The corrected code would look like this:

Code:
BEGIN
    dbms_output.put_line('testing anonymous block with auto_select feature in plsql developer');
END;
/

SELECT 'Hello from dual' FROM dual;

SELECT 'Bye from dual' FROM dual;
 
Thank you @Hilarion

That makes sense using the forward slash. It had been so long since using sqlplus for development that I forget those little nuances.

Thanks again
 
You can also select (highlight) the portion of the query you wish to execute. If you execute and only a portion of the query is selected, only the selected portion is executed.
 
Back
Top