I am written an application which performs a mass insert of data into a mySQL database. The way I am inserting the data is by using an ADOTable and update the database line by line, e.g.
AddInvoicesToDB(Invoice.CustomerCode, Invoice.TemplateNo, Invoice.ToBePrinted, Invoice.InvMemo, strSubTotal, Invoice.GST, Invoice.CustMsg, Invoice.Date);
procedure TfrmMain.AddInvoicesToDB(CustCode, TempNo, ToBePrinted, Memo, Amount,GST,CustMsg, GenDate : String);
begin
ADOTableInsertInvoices.Open; //open table
ADOTableInsertInvoices.Edit; //set to edit mode for insertion of data
//begin insert
ADOTableInsertInvoices.Insert;
//set values
ADOTableInsertInvoices.FieldByName('cust_code').Value := CustCode;
ADOTableInsertInvoices.FieldByName('temp_no').Value := StrToInt(TempNo);
ADOTableInsertInvoices.FieldByName('to_be_printed').Value := ToBePrinted;
ADOTableInsertInvoices.FieldByName('inv_memo').Value := Memo;
ADOTableInsertInvoices.FieldByName('amount').Value := strToFloat(Amount);
ADOTableInsertInvoices.FieldByName('gst').Value := strToFloat(GST);
ADOTableInsertInvoices.FieldByName('cust_msg').Value := CustMsg;
ADOTableInsertInvoices.FieldByName('gen_date').Value := GenDate;
//end insert
ADOTableInsertInvoices.Post;
end;
Is it more appropriate to use an INSERT Query rather than an ADOTable? The database will eventutally be holding 5000+ lines, so would an ADOTable be less efficient than an SQL Insert Query? Is there a better way of performing this operation?
------------------------------------
There's no place like 127.0.0.1
------------------------------------
AddInvoicesToDB(Invoice.CustomerCode, Invoice.TemplateNo, Invoice.ToBePrinted, Invoice.InvMemo, strSubTotal, Invoice.GST, Invoice.CustMsg, Invoice.Date);
procedure TfrmMain.AddInvoicesToDB(CustCode, TempNo, ToBePrinted, Memo, Amount,GST,CustMsg, GenDate : String);
begin
ADOTableInsertInvoices.Open; //open table
ADOTableInsertInvoices.Edit; //set to edit mode for insertion of data
//begin insert
ADOTableInsertInvoices.Insert;
//set values
ADOTableInsertInvoices.FieldByName('cust_code').Value := CustCode;
ADOTableInsertInvoices.FieldByName('temp_no').Value := StrToInt(TempNo);
ADOTableInsertInvoices.FieldByName('to_be_printed').Value := ToBePrinted;
ADOTableInsertInvoices.FieldByName('inv_memo').Value := Memo;
ADOTableInsertInvoices.FieldByName('amount').Value := strToFloat(Amount);
ADOTableInsertInvoices.FieldByName('gst').Value := strToFloat(GST);
ADOTableInsertInvoices.FieldByName('cust_msg').Value := CustMsg;
ADOTableInsertInvoices.FieldByName('gen_date').Value := GenDate;
//end insert
ADOTableInsertInvoices.Post;
end;
Is it more appropriate to use an INSERT Query rather than an ADOTable? The database will eventutally be holding 5000+ lines, so would an ADOTable be less efficient than an SQL Insert Query? Is there a better way of performing this operation?
------------------------------------
There's no place like 127.0.0.1
------------------------------------