i have a text file with 86400 lines it contains time in second and long and lat of a day (for example a car locations in a day)
these 86400 must saved on a table named `points`
also for each line i must do some process and save about 10 record on table `points_prop` and i must delete records in table if exists
my code is like this:
Code: Select all
AssignFile(myFile, 'OutputSGP4.txt' );
Reset(MyFile);
while (not Eof(myFile)) and (not Terminated) do
begin
UniQueryRead.SQL.Text := 'SELECT * FROM `gss`;';
UniQueryRead.Open;
UniQueryRead.First;
while (not UniQueryRead.Eof) do begin
UniQueryWrite.SQL.Text := 'Delete from `fds_gs` WHERE ......';
UniQueryWrite.Execute;
UniQueryWrite.SQL.Text := 'INSERT INTO `fds_gs` .....;';
UniQueryWrite.Params[0].DataType := ftString;
UniQueryWrite.Params[1].DataType := ftString;
UniQueryWrite.Execute;
end;
UniQueryWrite.SQL.Text := 'Delete from `fds_data` WHERE ....;';
UniQueryWrite.Params[0].DataType := ftString;
UniQueryWrite.Params[0].AsString := thePointDateStamp.ToString;
UniQueryWrite.Execute;
UniQueryWrite.SQL.Text := 'INSERT INTO `fds_data` (`type`,`x`,`y`,`z`,`vx`,`vy`,`vz`,`rtime`,`rgroup`,`ecfx`,`ecfy`,`ecfz`,'+
'`ecfvx`,`ecfvy`,`ecfvz`,`lat`,`lng`,`alt`,`sma`,`ecc`,`incl`,`argop`,`raan`,`truea`,`lighting`,`loctime`,`status`) VALUES '+
'(:f0,:f1,:f2,:f3,:f4,:f5,:f6,:f7,:f8,:f9,:f10,:f11,:f12,:f13,:f14,:f15,:f16,:f17,:f18,:f19,:f20,:f21,:f22,:f23,:f24,:f25,:f26);';
UniQueryWrite.Params[0].DataType := ftString;
UniQueryWrite.Execute;
end;
This code need about 0.5 second for each line! how can i speed up my proccess?