Trouble on trying to use BatchDML
Posted: 06.10.2021, 14:27
Hey guys!
I'm facing a trouble to use BatchDML on Delphi 2010, Zeos SVN 7683 and Firebird 2.1.7.
When I run the above code, I get a 'Invalid Variant-Type for String-Array binding!' exception on line 4303 of ZDbcStatement unit.
What I am doing wrong?
Thank you!
I'm facing a trouble to use BatchDML on Delphi 2010, Zeos SVN 7683 and Firebird 2.1.7.
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
indice : cardinal;
price, taxes : Currency;
begin
price := 0;
taxes := 0;
with ZQuery1 do
begin
Connection := ZConnection1;
Active := false;
SQL.Clear;
SQL.Add('insert into sometable (column_string1, column_string2, column_currency1, column_currency2)');
SQL.Add('values (:column_string1, :column_string2, :column_currency1, :column_currency2)');
Params.BatchDMLCount := 100;
for indice := 0 to Pred(Params.BatchDMLCount) do
begin
Params[0].SQLType := stUnicodeString;
Params[1].SQLType := stUnicodeString;
Params[2].SQLType := stCurrency;
Params[3].SQLType := stCurrency;
Randomize;
price := Random(1001) / 100;
taxes := 5.0;
Params[0].AsUnicodeStrings[indice] := 'array ' + IntToStr(indice);
Params[1].AsUnicodeStrings[indice] := 'product arraydml ' + IntToStr(indice);
Params[2].AsCurrencys[indice] := price;
Params[3].AsCurrencys[indice] := taxes;
end;
ExecSQL;
ShowMessage('Rows affected ' + IntToStr(RowsAffected));
end;
end;
What I am doing wrong?
Thank you!