I use a routine to detect if a field changed so I can limit the fields I send to the database to only the ones that changed. I added code to that routine today to handle BLOB fields, since they cannot be returned .AsVariant
, which is how OldValue
and NewValue
are returned. I have not tested this with all of my use cases, but so far it seems pretty solid.
function FieldChanged(DataSet: TDataSet; FieldName: string): Boolean;
var
fld: TField;
begin
fld := DataSet.FieldByName(FieldName);
if fld.IsBlob then
Exit((fld as TBlobField).Modified);
if (fld.OldValue = Null) and (fld.NewValue = Unassigned) then // This happens when a NULL field does not change
Exit(False)
else
Exit(fld.OldValue <> fld.NewValue);
end;