L'exemple de projet FireDAC (démonstration ArrayDML) avec deux c:\Users\Public\Documents\Embarcadero\Studio\19.0\Samples\Object Pascal\Database\FireDAC\Samples\Comp Layer\TFDQuery\ExecSQL\Batch\Batch.dproj
compile // W1058 Implicit string cast with potential data loss from string to rawbytestring
avertissements sur les missions Params[2].AsBlobs
indiquées avec //W 1058
:affectation de Params.asBlob sous FireDAC donne W1058
procedure TfrmBatch.btnExecSQLClick(Sender: TObject);
var
i: Integer;
iTm: LongWord;
begin
qrySelect.Open;
qrySelect.ServerDeleteAll(True);
qrySelect.Close;
with qryBatch do
if cbxBatchExec.Checked then begin
Params.ArraySize := StrToInt(edtArraySize.Text);
iTm := GetTickCount;
for i := 0 to Params.ArraySize - 1 do begin
Params[0].AsIntegers[i] := i;
Params[1].AsStrings[i] := 'string' + IntToStr(i);
Params[1].Size := 20;
if cbxInsertBlob.Checked then
Params[2].AsBlobs[i] := 'blob' + IntToStr(i); // W1058
end;
Execute(Params.ArraySize);
iTm := GetTickCount - iTm;
end
else begin
Params.ArraySize := 1;
iTm := GetTickCount;
for i := 0 to StrToInt(edtArraySize.Text) - 1 do begin
Params[0].AsInteger := i;
Params[1].AsString := 'string' + IntToStr(i);
Params[1].Size := 20;
if cbxInsertBlob.Checked then
Params[2].AsBlob := 'blob' + IntToStr(i); // W1058
ExecSQL;
end;
iTm := GetTickCount - iTm;
end;
StatusBar1.SimpleText := 'Time executing is ' + FloatToStr(iTm/1000.0) + ' sec.';
qrySelect.Open;
end;
Quelle est la bonne façon de résoudre ce problème? (Sous FireDAC, AsBlobs a été remplacé par TFDByteString
= RawByteString
sous Windows). Les deux acteurs comme un RawByteString()
ou une affectation Params[2].Value
font l'avertissement du compilateur aller loin, mais je ne suis pas sûr qu'il cela ne conduira pas à des problèmes potentiels ...