1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
| unit transfere;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation, Data.Win.ADODB, Data.DB,
DatabaseHelper, Data.sqlexpr, Data.DbxSqlite, FMX.Menus, System.Math.Vectors,
FMX.Controls3D, FMX.Objects3D, FMX.Types3D, FMX.Viewport3D;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
LBL_AvancementTransfere: TLabel;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
ADOTable1: TADOTable;
ADODataSet1: TADODataSet;
ProgressBar1: TProgressBar;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
LBL_AffTempsDebut: TLabel;
LBL_AffTempsFin: TLabel;
LBL_AffTempsExec: TLabel;
Label5: TLabel;
LBL_AffTempsTotExec: TLabel;
Label7: TLabel;
LBL_AffTempsMoyen: TLabel;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
var
ADOSelectQuery : TADOQuery;
ConnexionBdd: TDbHelper;
SQLInsertQuery : TSQLQuery;
J : Integer;
TempsDebut, TempsFin, TempsExec, TempsTotExec, TempsMoyen : TDateTime;
Cnt : Integer;
begin
Button1.Enabled := False;
ConnexionBdd := TDbHelper.Create('', '.\bdd\', 'bddSQLitre.db');
SQLInsertQuery := TSQLQuery.Create(nil);
with SQLInsertQuery do
begin
SQLConnection := ConnexionBdd.GetConnection;
Active := false;
SQL.Text := 'INSERT INTO Ma_Table (A, B,C, D, E, F, G, H, ';
SQL.Add('I, J, K, L, M, N, O, P, Q, R, S, T, U, V ');
SQL.Add('VALUES (:pA, :pB, :pC, :pD, ');
SQL.Add(':pE, :pF, :pG, :H, :pI, :pJ, :pK, :pL, ');
SQL.Add(':pM, :pN, :pO, :pP, :pQ, :pR, :pS, :pT, :pU, :pV;');
end;
ADOSelectQuery := TADOQuery.Create(nil);
with ADOSelectQuery do
begin
ConnectionString := 'Provider=MSDASQL.1; Persist Security Info=False; Data Source=bddParadox9';
Active := False;
SQL.Text := 'SELECT * FROM Ma_Table';
Open;
First;
end;
ProgressBar1.Create(nil);
ProgressBar1.Max := ADOSelectQuery.RecordCount;
J := 1;
TempsDebut := Time;
TempsTotExec := EncodeTime(0, 0, 0, 0);
Cnt := 0;
while (SQLInsertQuery.EOF) do
begin
SQLInsertQuery.ParamByName('pA').AsInteger := StrToInt(VarToStr(ADOSelectQuery['A']));
SQLInsertQuery.ParamByName('pB').AsString := VarToStr(ADOSelectQuery['B']);
SQLInsertQuery.ParamByName('pC').AsString := VarToStr(ADOSelectQuery['C']);
SQLInsertQuery.ParamByName('pD').AsString := VarToStr(ADOSelectQuery['D']);
SQLInsertQuery.ParamByName('pE').AsString := VarToStr(ADOSelectQuery['E']);
SQLInsertQuery.ParamByName('pF').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['F']), 0);
SQLInsertQuery.ParamByName('pG').AsString := VarToStr(ADOSelectQuery['G']);
SQLInsertQuery.ParamByName('pH').AsString := VarToStr(ADOSelectQuery['H']);
SQLInsertQuery.ParamByName('pI').AsString := VarToStr(ADOSelectQuery['I']);
SQLInsertQuery.ParamByName('pJ').AsString := VarToStr(ADOSelectQuery['J']);
SQLInsertQuery.ParamByName('pK').AsString := VarToStr(ADOSelectQuery['K']);
SQLInsertQuery.ParamByName('pL').AsString := VarToStr(ADOSelectQuery['L']);
SQLInsertQuery.ParamByName('pM').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['M']), 0);
SQLInsertQuery.ParamByName('pN').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['N']), 0);
SQLInsertQuery.ParamByName('pO').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['O']), 0);
SQLInsertQuery.ParamByName('pP').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['P']), 0);
SQLInsertQuery.ParamByName('pQ').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['Q']), 0);
SQLInsertQuery.ParamByName('pR').AsString := VarToStr(ADOSelectQuery['R']);
SQLInsertQuery.ParamByName('pS').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['S']), 0);
SQLInsertQuery.ParamByName('pT').AsString := VarToStr(ADOSelectQuery['T']);
SQLInsertQuery.ParamByName('pU').AsString := VarToStr(ADOSelectQuery['U']);
SQLInsertQuery.ParamByName('pV').AsInteger := StrToIntDef(VarToStr(ADOSelectQuery['V']), 0);
SQLInsertQuery.ExecSQL;
Inc(Cnt, 1);
ProgressBar1.Value := J;
LBL_AvancementTransfere.Text := 'Nombre d''enregistrements transférés vers SQLiteBrowser : ' + IntToStr(J)
+ '/'
+ IntToStr(ADOSelectQuery.RecordCount);
Inc(J);
Application.ProcessMessages;
{ TDateTime }
LBL_AffTempsDebut.Text := FormatDateTime('ss.zzz', TempsDebut);
TempsFin := Time;
LBL_AffTempsFin.Text := FormatDateTime('ss.zzz', TempsFin);
TempsExec := TempsFin - TempsDebut;
LBL_AffTempsExec.Text := FormatDateTime('ss.zzz', TempsExec);
TempsTotExec := TempsTotExec + TempsExec;
LBL_AffTempsTotExec.Text := FormatDateTime('hh:nn:ss.zzz', TempsTotExec);
TempsMoyen := TempsTotExec / Cnt;
LBL_AffTempsMoyen.Text := FormatDateTime('ss.zzz', TempsMoyen);
TempsDebut := TempsFin;
ADOSelectQuery.Next;
end;
ADOSelectQuery.Close;
ADOSelectQuery.DisposeOf;
SQLInsertQuery.DisposeOf;
ConnexionBdd.Close;
end;
end. |
Partager