Execute single statement in SQL window

vachi

Member
My SQL window usually contains multiple SQL statements, separeted by ";"

What is the easiest way to execute only one statement at the cursor position? Right now I must
* move the cursor to the beginning of the statement
* highlight the whole statement
* hit execute (F8)
If there is a one key (or two-key) shortcut for this I would like to know.

(FYI, in SQL Developer F9 execute the single statement at cursor position)
 
Hi,

Tools/Preferences/SQL Window there is an option AutoSelect Statement.

If you activate it, the statement only at cursor position will be executed.

To execute all statements, and get each resultset at an separate tab, mark all, an then hit F8
 
Hi, I am unable to use this feature on 12.0.4.1826. Even though the Auto select statement is on it executes all statements on the window. Is this a bug in this version, please advise. Also it will be helpful if the default windows features available on the editor to maximize fonts with mouse scroll etc.
 
Auto select feature works on the statement that the cursor is on. If you selected the statements yourself, then it will execute all the statements selected ignoring the one the cursor is on.

For example if I have:

select sysdate as date1 from dual;
select sysdate as date2 from dual;
select sysdate as date3 from dual;

My cursor is on 2nd line (anywhere) and hit F8 (Exec) key you should get only date2.

If I put the cursor on 2nd line do a Ctrl-A to select all and hit F8 (Exec) key you should get all 3 dates.

 
If one of the statements is a PL/SQL call, then the Auto-select statement preference won't work. It works fine when all the statements are SQL statements.

Regards,
Michael
 
You absolutely can use Auto-select statement with mixed SQL and PL/SQL blocks: we do it all the time. You need a forward slash in the first position of the line immediately after the block.

SELECT *
FROM dual;

DECLARE
v_time DATE;
BEGIN
SELECT SYSDATE
INTO v_time
FROM dual;
END;
/

SELECT *
FROM dual;
 
Last edited:
Back
Top