Print Thread
Execute query without selecting entire query
#53104 02/11/16 04:07 PM
Joined: Feb 2016
Posts: 4
C
cmatta Offline OP
Member
OP Offline
Member
C
Joined: Feb 2016
Posts: 4
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

Re: Execute query without selecting entire query
cmatta #53106 02/11/16 04:14 PM
Joined: Sep 2004
Posts: 476
Munich, Germany
Member
Offline
Member
Joined: Sep 2004
Posts: 476
Munich, Germany
You can use this option in preferences:
Window Types - SQL Window - AutoSelect statement


Regards,
Berny
Re: Execute query without selecting entire query
Bernhard S #53107 02/11/16 04:19 PM
Joined: Feb 2016
Posts: 4
C
cmatta Offline OP
Member
OP Offline
Member
C
Joined: Feb 2016
Posts: 4
Got it. Thanks

Re: Execute query without selecting entire query
cmatta #53110 02/12/16 06:02 AM
Joined: Feb 2003
Posts: 392
The Netherlands
Member
Offline
Member
Joined: Feb 2003
Posts: 392
The Netherlands
Or, you can use my Execute Current Statement plugin. Check http://bar-solutions.com/plugins.php

Re: Execute query without selecting entire query
Bernhard S #53124 02/15/16 05:50 PM
Joined: Sep 2009
Posts: 197
Krakow, Poland
Member
Offline
Member
Joined: Sep 2009
Posts: 197
Krakow, Poland
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).

Re: Execute query without selecting entire query
patch #53611 06/14/16 06:27 PM
Joined: Jun 2016
Posts: 5
B
Member
Offline
Member
B
Joined: Jun 2016
Posts: 5
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:

[quote]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;
[/quote]

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 by Benny; 06/14/16 06:35 PM.
Re: Execute query without selecting entire query
Benny #53612 06/14/16 09:29 PM
Joined: Sep 2009
Posts: 197
Krakow, Poland
Member
Offline
Member
Joined: Sep 2009
Posts: 197
Krakow, Poland
[quote=Benny]
[...] 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.
[/quote]
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;

Re: Execute query without selecting entire query
Hilarion #53614 06/15/16 05:12 PM
Joined: Jun 2016
Posts: 5
B
Member
Offline
Member
B
Joined: Jun 2016
Posts: 5
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

Re: Execute query without selecting entire query
Benny #53629 06/22/16 11:50 AM
Joined: May 2016
Posts: 3
Ohio, USA
R
Member
Offline
Member
R
Joined: May 2016
Posts: 3
Ohio, USA
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.


Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.046s Queries: 15 (0.015s) Memory: 2.5371 MB (Peak: 3.0394 MB) Data Comp: Off Server Time: 2024-05-21 14:08:14 UTC
Valid HTML 5 and Valid CSS