If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Inserting multiple rows at a time into table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-09, 07:56
ravishankar.dm ravishankar.dm is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
Inserting multiple rows at a time into table

Hi,

I am trying to implement functionality that will insert multiple rows at a time irrespective of the database used. The SQL command should be compatible across all the database. If any one knew about this please let me know as its very urgent.

Thanks in advance
Ravishankar
Reply With Quote
  #2 (permalink)  
Old 03-11-09, 08:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
can't be done

next question?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-11-09, 08:37
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Do ya not reckon (for major RDBMSs anyway)?
Pseudo code:
Code:
CREATE TABLE dummy (nowt INT)
INSERT INTO dummy (nowt) VALUES(0)

INSERT INTO destination (col1, col2, col3)
SELECT 'this', 'that', 'the other'
FROM dummy
UNION
SELECT 'something', 'nothing', 'anything'
FROM dummy
..........
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #4 (permalink)  
Old 03-11-09, 08:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
actually, for major database systems, just use this, it's standard SQL --
Code:
INSERT 
  INTO destination 
     ( col1, col2, col3 )
VALUES
     ( 'this', 'that', 'the other' )
   , ( 'something', 'nothing', 'anything' )
you might be surprised which microsoft database products would not be considered "major" by this criterion

Edit: it's "F641, Row and table constructors" and i just realized it's optional -- apologies for the hasty snipe at ms


heh -- i said "snipe"


__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Last edited by r937; 03-11-09 at 08:51.
Reply With Quote
  #5 (permalink)  
Old 03-12-09, 00:11
ravishankar.dm ravishankar.dm is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
Will these SQL commands work for almost all databases like oracle,db2 and ms sql server
Reply With Quote
  #6 (permalink)  
Old 03-12-09, 00:56
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
yes, almost all of those

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 03-12-09, 05:21
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Just so you know Rudy - SQL Server 2008 supports this construct
__________________
George
Twitter | Blog
Reply With Quote
  #8 (permalink)  
Old 03-13-09, 12:26
loquin loquin is offline
Super Moderator
 
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
PostgreSQL does as well.
__________________
Lou
使大吃一惊
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Reply With Quote
  #9 (permalink)  
Old 03-13-09, 14:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
as does mysql

the point wasn't to list the ones that do support row constructors, which is standard sql, but to highlight the "major" database systems that don't support it

actually, the original question was whether there was a way to do it the same way across all database systems and the answer is still "no"

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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

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