6.2.7- Can not access a DML array as a single value
Posted: Mon 14 Sep 2015 17:11
I have tried your sample:
http://blog.devart.com/using-batch-oper ... nents.html
But I have received this error: "Can not access a DML array as a single value"
I have tried INSERT and DELETE code with TUniQuery with SQLServer 2008, Firebird 2.52 and XE8/10 Seattle
Thanks
Alessandro
http://blog.devart.com/using-batch-oper ... nents.html
But I have received this error: "Can not access a DML array as a single value"
I have tried INSERT and DELETE code with TUniQuery with SQLServer 2008, Firebird 2.52 and XE8/10 Seattle
Code: Select all
procedure TForm43.ButtonInsClick(Sender: TObject);
var
i: Integer;
begin
// describe the SQL query
Query1.SQL.Text := 'INSERT INTO BATCH_TEST VALUES (:ID, :F_INTEGER, :F_FLOAT, :F_STRING, :F_DATE)';
// define the parameter types passed to the query :
Query1.Params[0].DataType := ftInteger;
Query1.Params[1].DataType := ftInteger;
Query1.Params[2].DataType := ftFloat;
Query1.Params[3].DataType := ftWideString;
Query1.Params[4].DataType := ftDateTime;
// specify the array dimension:
Query1.Params.ValueCount := 1000;
// populate the array with parameter values:
for i := 0 to Query1.Params.ValueCount - 1 do begin
Query1.Params[0][i].AsInteger := i + 1;
Query1.Params[1][i].AsInteger := i + 2000 + 1;
Query1.Params[2][i].AsFloat := (i + 1) / 12;
Query1.Params[3][i].AsString := 'Values ' + IntToStr(i + 1);
Query1.Params[4][i].AsDateTime := Now;
end;
// insert 1000 rows into the BATCH_TEST table
Query1.Execute(1000);
ShowMessage('ok');
end;
procedure TForm43.ButtonDelClick(Sender: TObject);
var
i: Integer;
begin
// describe the SQL query
Query1.SQL.Text := 'DELETE FROM BATCH_TEST WHERE ID=:ID';
// define parameter types passed to the query:
Query1.Params[0].DataType := ftInteger;
// specify the array dimension
Query1.Params.ValueCount := 1000;
// populate the arrays with parameter values
for i := 0 to 1000 - 1 do
Query1.Params[0][i].AsInteger := i + 3000 + 1;
// delete 1000 rows from the BATCH_TEST table
Query1.Execute(1000);
end;
Alessandro