| |
|
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.
|
 |

03-11-09, 07:56
|
|
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
|
|

03-11-09, 08:00
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
can't be done
next question? 
|
|

03-11-09, 08:37
|
|
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.
|
|
|

03-11-09, 08:47
|
|
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"

|
Last edited by r937; 03-11-09 at 08:51.
|

03-12-09, 00:11
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 2
|
|
Will these SQL commands work for almost all databases like oracle,db2 and ms sql server
|
|

03-12-09, 00:56
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
yes, almost all of those

|
|

03-12-09, 05:21
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Just so you know Rudy - SQL Server 2008 supports this construct 
|
|

03-13-09, 12:26
|
|
Super Moderator
|
|
Join Date: Jun 2004
Location: Arizona, USA
Posts: 1,797
|
|
__________________
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
|
|

03-13-09, 14:33
|
|
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"

|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|