I have a situation where, sometime, I need change the data of two register of same type, the second just after the first. The problem arises on the second update as it looks like Zeos is replicating the value of ALL field when they are NULL. The code is like below:
Code: Select all
with SQLTest do
begin
Close;
SQL.Clear;
SQL.Add('UPDATE test_table SET field1 = :field1, field2 = :field2, field3 = :field3,');
SQL.Add('date_test = :date_test, state_test = :state_test');
SQL.Add('WHERE (cod_testtable = :cod_testtable)');
if TwoUpdatesCheckBox.Checked then
begin
ParamByName('FIELD1').AsInteger := 44;
ParamByName('FIELD2').Clear;
ParamByName('FIELD3').AsInteger := 45;
ParamByName('DATE_TEST').AsDateTime := Now;
ParamByName('STATE_TEST').AsString := 'D';
ParamByName('COD_TESTTABLE').AsInteger := 2;
ExecSQL;
end;
ParamByName('FIELD1').AsInteger := StrToInt(Field1.Text);
ParamByName('FIELD2').AsInteger := StrToInt(Field2.Text);
ParamByName('FIELD3').AsInteger := StrToInt(Field3.Text);
ParamByName('DATE_TEST').AsDateTime := Now;
ParamByName('STATE_TEST').AsString := 'A';
ParamByName('COD_TESTTABLE').AsInteger := 3;
ExecSQL;
end;
I am using TESTING_REV679 version.
Thank you.