Einzelnen Beitrag anzeigen

nahpets
(Gast)

n/a Beiträge
 
#11

AW: Kleiner Geschwindigkeitstest von Insert

  Alt 18. Dez 2016, 16:10
na wenn jetzt das "Form" noch wegfällt, wären wir bei der Version, welche nach meinem Bauchgefühl am schnellsten und "am saubersten" wäre
Delphi-Quellcode:
function test3a(testzahl: integer): string;
var
  a: integer;
  p: TParam;
begin
  Form1.ZQuery1.SQL.Text := 'begin transaction;';
  Form1.ZQuery1.ExecSQL;
  Form1.ZQuery1.SQL.Text := 'Insert into daten2 (zahl) values (:zahl);';
  Form1.ZQuery1.Prepare;
  p := Form1.ZQuery1.ParamByName('Zahl');
  for a := 1 to testzahl do
  begin
    p.AsInteger := a;
    Form1.ZQuery1.ExecSQL;
  end;
  Form1.ZQuery1.SQL.Text := 'Commit;';
  Form1.ZQuery1.ExecSQL;
end;
Könntest Du Dich damit anfreunden?
Delphi-Quellcode:
function test3a(qry : TZQuery; testzahl: integer): string;
var
  a: integer;
  p: TParam;
begin
  qry.SQL.Text := 'begin transaction;';
  qry.ExecSQL;
  qry.SQL.Text := 'Insert into daten2 (zahl) values (:zahl);';
  qry.Prepare;
  p := qry.ParamByName('Zahl');
  for a := 1 to testzahl do
  begin
    p.AsInteger := a;
    qry.ExecSQL;
  end;
  qry.SQL.Text := 'Commit;';
  qry.ExecSQL;
end;
Der weiter oben beschriebene Aufruf wäre dann:
Delphi-Quellcode:
Form1.ZQuery1.SQL.Text := 'Delete from daten2';
Form1.ZQuery1.ExecSQL;
test3a(Form1.ZQuery1,testzahl);
Wobei das auch noch schöner ginge.

Befinden sich Test3a ... im Quelltext von Form1, dann ist das hier überflüssig.
Delphi-Quellcode:
ZQuery1.SQL.Text := 'Delete from daten2';
ZQuery1.ExecSQL;
test3a(ZQuery1,testzahl);
Kann SQLite eigentlich auch
Delphi-Quellcode:
ZQuery1.SQL.Text := 'truncate table daten2';
ZQuery1.ExecSQL;
test3a(ZQuery1,testzahl);
  Mit Zitat antworten Zitat