Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toad for Oracle..How to execute multiple statements?

Tags:

oracle

toad

I have some 800-1200 INSERT statements generated from an excel sheet. I want to run these in TOAD - Oracle db.

If I press F9, it runs only one line and F5 gives me syntax issue and do not seem to work? What am I missing here?

like image 220
user1191463 Avatar asked Feb 07 '12 03:02

user1191463


People also ask

How do I run multiple SQL queries in Oracle?

In SqlDeveloper preferences: Tools > Preferences > Database > Worksheet check the option for New Worksheet to use unshared connction . This will allow you to execute multiple queries at the same time, each in each tab.

How do I run a Toad statement?

Shift-F9 executes the current SQL statement. If you are working with SQL in a script, highlight the SQL in the script and press F9 to execute the single SQL statement only.


2 Answers

F9 executes only one statement. By default Toad will try to execute the statement wherever your cursor is or treat all the highlighted text as a statement and try to execute that. A ; is not necessary in this case.

F5 is "Execute as Script" which means that Toad will take either the complete highlighted text (or everything in your editor if nothing is highlighted) containing more than one statement and execute it like it was a script in SQL*Plus. So, in this case every statement must be followed by a ; and sometimes (in PL/SQL cases) ended with a /.

like image 116
John Doyle Avatar answered Sep 21 '22 01:09

John Doyle


Wrap the multiple statements in a BEGIN END block to make them one statement and add a slash after the END; clause.

BEGIN   insert into books   (id, title, author)   values   (books_seq.nextval, 'The Bite in the Apple', 'Chrisann Brennan');    insert into books   (id, title, author)   values   (books_seq.nextval, 'The Restaurant at the End of the Universe', 'Douglas Adams'); END; / 

That way, it is just ctrl-a then ctrl-enter and it goes.

like image 38
CSQ Avatar answered Sep 18 '22 01:09

CSQ