Thread View: borland.public.cppbuilder.database.multi-tier
4 messages
4 total messages
Started by Clayton M. Arends
Sun, 21 Nov 1999 00:00
Multiple INSERT in one Query
Author: Clayton M. Arends
Date: Sun, 21 Nov 1999 00:00
Date: Sun, 21 Nov 1999 00:00
22 lines
1450 bytes
1450 bytes
Hello all,
I am interested in writing a query that would insert data into multiple
records with one execute. I am currently doing the this using multiple
exec's and updating the parameters in a loop but for performance purposes I
wanted to see if it would be faster to execute all at once. The help for
BDE SQL says that INSERT "Adds one or more new rows of data in a table."
I've tried the following (and other variations) without success. I was
wondering if anyone out there knows of a way that this can be done:
query->SQL->Add("INSERT INTO SOMETABLE);
query->SQL->Add(" ( ID, PART )");
query->SQL->Add("VALUES ( (0, 0), (1, 1), (2, 2), (3, 3), (4, 4) )");
query->ExecSQL();
So the effect would be that SOMETABLE would contain five new records with ID
and PART initialized to 0 in the first record, 1 in the next, etc.
Any help would be appreciated, thank you,
- Clayton
Re: Multiple INSERT in one Query
Author: Jeff Overcash (TeamB)
Date: Sun, 21 Nov 1999 00:00
Date: Sun, 21 Nov 1999 00:00
25 lines
1517 bytes
1517 bytes
"Clayton M. Arends" wrote:
>
> Hello all,
>
> I am interested in writing a query that would insert data into multiple
> records with one execute. I am currently doing the this using multiple
> exec's and updating the parameters in a loop but for performance purposes I
> wanted to see if it would be faster to execute all at once. The help for
> BDE SQL says that INSERT "Adds one or more new rows of data in a table."
>
The more part is if you are using a select statment to fill out the values to
insert. Doing it the way you are you can't write SQL that will insert the
multiple rows that way. Do it row by row like you are right now.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Re: Multiple INSERT in one Query
Author: Clayton M. Arends
Date: Sun, 21 Nov 1999 00:00
Date: Sun, 21 Nov 1999 00:00
8 lines
794 bytes
794 bytes
Thanks Jeff, That's all I needed to know. Why does the help mention "Adds one or more new rows of data in a table"? Was the help writer overzealous? Thanks again. 'till next time, - Clayton
Re: Multiple INSERT in one Query
Author: Jeff Overcash (TeamB)
Date: Sun, 21 Nov 1999 00:00
Date: Sun, 21 Nov 1999 00:00
25 lines
1483 bytes
1483 bytes
No, it can insert multiple rows, but only with a select statement embedded like
Insert into MyTable (c1, c2, c3) Values Select col1, col2, col3 from
MySourceTable
That will do multiple inserts. So the help is correct that the Insert SQL
statement can insert multiple rows, but only in a specific syntax.
"Clayton M. Arends" wrote:
>
> Thanks Jeff,
>
> That's all I needed to know. Why does the help mention "Adds one or more
> new rows of data in a table"? Was the help writer overzealous?
>
> Thanks again. 'till next time,
>
> - Clayton
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads