I have written an App which inserts about 5000 lines into the database. The way I do it is somthing like this:
This is all working okay, however I would like an opinion on whether there is a better or more efficient way.
Thanks.
------------------------------------
There's no place like 127.0.0.1
------------------------------------
Code:
//loop
SQLInsertText := SQLInsertText +
'(' + QuotedStr(Invoice.CustomerCode) + ', ' + Invoice.TemplateNo +
', ' + QuotedStr('-') + ', ' + QuotedStr('-') + ', ' + QuotedStr('-') +
', ' + FloatToStr(0) + ', ' + Invoice.Amount + ', ' + QuotedStr(strTaxCode) +
', ' + Invoice.Qty + ', ' + QuotedStr(Invoice.ItemCode) +
', ' + QuotedStr(Invoice.InvDesc) + ', ' + QuotedStr('-') +
', ' + QuotedStr(Invoice.StartDate) + ', ' + QuotedStr(Invoice.EndDate) +
', ' + QuotedStr(Invoice.AutoRollover) +
', ' + IntToStr(i) + '), ';
.....
SQLInsertText := SQLInsertText +
'(' + QuotedStr(Invoice.CustomerCode) + ', ' + Invoice.TemplateNo +
', ' + QuotedStr(Invoice.TemplateType) + ', ' + QuotedStr(Invoice.ToBePrinted) +
', ' + QuotedStr(Invoice.InvMemo) + ', ' + FloatToStr(0) +
', ' + Invoice.Amount + ', ' + QuotedStr(strTaxCode) + ', ' + QuotedStr('0') +
', ' + QuotedStr('*header_line*') + ', ' + QuotedStr('*header_line*') +
', ' + QuotedStr(Invoice.CustMsg) + ', ' + QuotedStr(Invoice.StartDate) +
', ' + QuotedStr(Invoice.EndDate) + ', ' + QuotedStr(Invoice.AutoRollover) +
', ' + IntToStr(i) + ')';
....
try
//Add header data to database
AddInvoicesToDB(SQLInsertText);
except on e:exception do
begin
MessageDlg('Error' + #13#10 + #13#10 + e.Message, mtInformation, [mbOK], 0);
exit;
end
end;
//procedure to add extracted invoice information to database
procedure TfrmMain.AddInvoicesToDB(SQL : String);
begin
ADOCommandInsert.CommandText := 'INSERT INTO invoice_data VALUES ' +
SQL;
ADOCommandInsert.Execute;
end;
This is all working okay, however I would like an opinion on whether there is a better or more efficient way.
Thanks.
------------------------------------
There's no place like 127.0.0.1
------------------------------------