Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > multiple row insert, one SQL stmt

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-03-08, 14:04
chuck_forbes chuck_forbes is offline
Registered User
 
Join Date: Dec 2003
Posts: 848
multiple row insert, one SQL stmt

So MySQL allows this syntax (multiple rows on an INSERT). Does Oracle have any equivalent?

Code:
INSERT INTO BookTable ( BookId , Title , Description ) VALUES ( 101, "Moby Dick", "Whale book"; 101, "Beaches", "Chick book"; 101, "From Good to Great", "Boss book"; 101, "C#", "Nerd book" )
Reply With Quote
  #2 (permalink)  
Old 04-03-08, 15:29
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 3,566
Code:
insert ALL INTO NR_ATG_ORDER_REL VALUES ('o27290008', 0, 'order1001023') INTO NR_ATG_ORDER_REL VALUES ('o27400001', 0, 'order1001071') INTO NR_ATG_ORDER_REL VALUES ('o27400002', 0, 'order1001073') SELECT * FROM DUAL /
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
Reply With Quote
  #3 (permalink)  
Old 04-03-08, 16:21
chuck_forbes chuck_forbes is offline
Registered User
 
Join Date: Dec 2003
Posts: 848
Weird ... why is the "SELECT * FROM DUAL" required? I guess I got it also to work with

Code:
create table mult_ins (f1 number, f2 number); insert all into mult_ins values (1,100) into mult_ins values (2,200) into mult_ins values (3,300) select * from mult_ins where rownum < 2

but the SELECT at the end is befuddling me ...
Reply With Quote
  #4 (permalink)  
Old 04-03-08, 18:04
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 3,566
>why is the "SELECT * FROM DUAL" required?
I did NOT state it was "required".
I posted what I know works.
If you don't like this solution, my feelings won't be hurt if you obtain a different one.
Other, even better, solutions may exists, but it is not worth my time to try to find 1.

With free advice, you get what you paid for it.
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
Reply With Quote
  #5 (permalink)  
Old 04-03-08, 19:54
chuck_forbes chuck_forbes is offline
Registered User
 
Join Date: Dec 2003
Posts: 848
It was less of an antagonistic interrogation, than it was simple curiosity. The syntax seemed strange, is all. I was working from home & didn't have my Oracle bookmarks available to look it up in the documentation. Or at least, I didn't want to take the time to search for it via Google.

I went ahead and sought it out anyway, since your guarded response made me even more curious, and after reading the docs it still strikes me as odd. I'll have to play with it a bit more until I get the hang of it, and figure out what INSERT ALL, in general, is really useful for.

Thanks for showing me something new.
--=Chuck
Reply With Quote
  #6 (permalink)  
Old 04-03-08, 23:37
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,554
the code in post #1 is wrong, you need more parentheses
Code:
INSERT INTO BookTable ( BookId , Title , Description ) VALUES ( 101, "Moby Dick", "Whale book" ) , ( 102, "Beaches", "Chick book" ) , ( 103, "From Good to Great", "Boss book" ) , ( 104, "C#", "Nerd book" )
also, there is nothing but pain and frustration waiting for you if you insert 4 different books with the same bookid

__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon
Reply With Quote
  #7 (permalink)  
Old 04-04-08, 09:35
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Quote:
Originally Posted by chuck_forbes
Weird ... why is the "SELECT * FROM DUAL" required?
The example above is an "unanticipated" use of Oracle's multi-table insert statement, which is really intended for use in transforming data. There are some good examples here in the Oracle SQL Reference.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On