Board index » delphi » Multiple SQL Insert Statements

Multiple SQL Insert Statements

I guess a TADOCommand object would be more appropriate for this work.

Hardy

Quote
Arnold Johnson <Arno...@win-pro.demon.co.uk> wrote in message

news:KHW5DMA8ahK4EwZD@win-pro.demon.co.uk...
Quote
> How does one write a query to do multiple inserts?
> It is needed to create sample data for testing.
> e.g.
> Table insTest with Columns aCode and aName
> I would like to write a query or an .sql file
> with the following

> Insert into insTest (aCode, aName) Values ('01', 'FirstLine');
> Insert into insTest (aCode, aName) Values ('02', 'SecondLine');
> Insert into insTest (aCode, aName) Values ('03', 'LookAtMe');
> Insert into insTest (aCode, aName) Values ('04', 'WhoAreYou');
> Insert into insTest (aCode, aName) Values ('05', 'WhatIsYourName');
> Insert into insTest (aCode, aName) Values ('06', 'Laugh4Me');
> Insert into insTest (aCode, aName) Values ('07', 'Smile8Me');

> I could do this with InterBase using WISQL or load it into WISQL from a
> script file.
> Tried it with TADOQuery and it complains after doing the first insert.
> Note the insert statement would be in an inserts.sql file and all I want
> to do is
> ttADOQuery.SQL.Clear;
> ttADOQuery.LoadFromFile('MySQL.SQL');
> ttADOQuery.Execute;

> --
> Arnold Johnson

 

Re:Multiple SQL Insert Statements


How does one write a query to do multiple inserts?
It is needed to create sample data for testing.
e.g.
Table insTest with Columns aCode and aName
I would like to write a query or an .sql file
with the following

Insert into insTest (aCode, aName) Values ('01', 'FirstLine');
Insert into insTest (aCode, aName) Values ('02', 'SecondLine');
Insert into insTest (aCode, aName) Values ('03', 'LookAtMe');
Insert into insTest (aCode, aName) Values ('04', 'WhoAreYou');
Insert into insTest (aCode, aName) Values ('05', 'WhatIsYourName');
Insert into insTest (aCode, aName) Values ('06', 'Laugh4Me');
Insert into insTest (aCode, aName) Values ('07', 'Smile8Me');

I could do this with InterBase using WISQL or load it into WISQL from a
script file.
Tried it with TADOQuery and it complains after doing the first insert.
Note the insert statement would be in an inserts.sql file and all I want
to do is
ttADOQuery.SQL.Clear;
ttADOQuery.LoadFromFile('MySQL.SQL');
ttADOQuery.Execute;

--
Arnold Johnson

Re:Multiple SQL Insert Statements


Quote
>I guess a TADOCommand object would be more appropriate for this work.

I'll try it out and see. I'll let the NG know how I faired on, incase
others need this kind of facility.

Quote

>Hardy

>Arnold Johnson <Arno...@win-pro.demon.co.uk> wrote in message
>news:KHW5DMA8ahK4EwZD@win-pro.demon.co.uk...
>> How does one write a query to do multiple inserts?
>> It is needed to create sample data for testing.
>> e.g.
>> Table insTest with Columns aCode and aName
>> I would like to write a query or an .sql file
>> with the following

>> Insert into insTest (aCode, aName) Values ('01', 'FirstLine');
>> Insert into insTest (aCode, aName) Values ('02', 'SecondLine');
>> Insert into insTest (aCode, aName) Values ('03', 'LookAtMe');
>> Insert into insTest (aCode, aName) Values ('04', 'WhoAreYou');
>> Insert into insTest (aCode, aName) Values ('05', 'WhatIsYourName');
>> Insert into insTest (aCode, aName) Values ('06', 'Laugh4Me');
>> Insert into insTest (aCode, aName) Values ('07', 'Smile8Me');

>> I could do this with InterBase using WISQL or load it into WISQL from a
>> script file.
>> Tried it with TADOQuery and it complains after doing the first insert.
>> Note the insert statement would be in an inserts.sql file and all I want
>> to do is
>> ttADOQuery.SQL.Clear;
>> ttADOQuery.LoadFromFile('MySQL.SQL');
>> ttADOQuery.Execute;

>> --
>> Arnold Johnson

--
Arnold Johnson

Other Threads