Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I do multiple INSERT INTO's...??? 1

Status
Not open for further replies.

WildWest

Programmer
Apr 2, 2002
111
0
0
US
Hi gurus!!!! I want to be able to do multiple INSERT INTO's in one execution of SQL. How do I do it?

INSERT INTO MYTABLE (CCN, PRJ) VALUES ('100', '5102566')
INSERT INTO MYTABLE (CCN, PRJ) VALUES ('100', '1000238')

Please advise. Thanks in advance!!!!
 
are you writing pl/sql? use loop structure.

if not, write a script, i.e. test.sql, put these two lines in the file:-

INSERT INTO MYTABLE (CCN, PRJ) VALUES ('100', '5102566');
INSERT INTO MYTABLE (CCN, PRJ) VALUES ('100', '1000238');

commit;


then run the script at sql command prompt:-

sql>@test



~za~
You can't bring back a dead thread!
 
In short, you don't. Each INSERT only inserts one row (unless you are inserting values using a subquery).
 
I am using TOAD and I get an ORA-00911 error on the first semicolon.

I tried the following...

INSERT INTO MYTABLE (CCN, PRJ) VALUES ('100', '5102566');
INSERT INTO MYTABLE (CCN, PRJ) VALUES ('100', '1000238');
commit;

I'm not able to execute it as a filename.sql script file because I'm using a Web server via ColdFusion to execute the SQL Statement that are programmatically generated.

Please help if you can. Thanks!!!
 
If you do need 1 SQL STATEMENT, you may use this one:

INSERT INTO MYTABLE (CCN, PRJ)
select '100', '5102566' from dual
union
select '100', '1000238' from dual


Regards, Dima
 
You may need to put a carriage return in-between the two statements to run them using the "Run the current statement" icon. It's a TOAD thing. Otherwise in TOAD you can run both using the two arrows icon (one above the other) which will run everthing in your window as a script.

Hope its of some help.

David
 
Thanks sem! That's what I was looking for!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top