Einzelnen Beitrag anzeigen

Benutzerbild von user0815
user0815

Registriert seit: 5. Okt 2007
331 Beiträge
 
Delphi XE2 Professional
 
#18

AW: SQL "Update or Insert" langsam

  Alt 3. Jan 2017, 10:14
Zugriff erfolgt über: IBDAC
kurz mal geguckt: https://www.devart.com/ibdac/docs/?batchops.htm

Batch INSERT operation sample
Let’s try to insert 1000 rows to the BATCH_TEST table using a Batch Insert operation:

Delphi-Quellcode:
var
  i: Integer;
begin
  // describe the SQL query
  IBCQuery1.SQL.Text := 'INSERT INTO BATCH_TEST VALUES (:ID, :F_INTEGER, :F_FLOAT, :F_STRING, :F_DATE)';

  // define the parameter types passed to the query :
  IBCQuery1.Params[0].DataType := ftInteger;
  IBCQuery1.Params[1].DataType := ftInteger;
  IBCQuery1.Params[2].DataType := ftFloat;
  IBCQuery1.Params[3].DataType := ftString;
  IBCQuery1.Params[4].DataType := ftDateTime;

  // specify the array dimension:
  IBCQuery1.Params.ValueCount := 1000;

  // populate the array with parameter values:
  for i := 0 to IBCQuery1.Params.ValueCount - 1 do
  begin
    IBCQuery1.Params[0][i].AsInteger := i + 1;
    IBCQuery1.Params[1][i].AsInteger := i + 2000 + 1;
    IBCQuery1.Params[2][i].AsFloat := (i + 1) / 12;
    IBCQuery1.Params[3][i].AsString := 'Values ' + IntToStr(i + 1);
    IBCQuery1.Params[4][i].AsDateTime := Now;
  end;

  // insert 1000 rows into the BATCH_TEST table
  IBCQuery1.Execute(1000);
end;
  Mit Zitat antworten Zitat