I have a SQL table containing among other fields, two memo fields. I am saving records using ApplyUpdates, calling a stored procedure. I determine the old or new value of a field using the following logic:
function DeltaValueStr(DeltaDS: TDataSet; FieldName: String): Variant;
begin
with DeltaDS as TCustomClientDataSet do
begin
Result := DeltaDS.FindField(FieldName).NewValue;
if VarIsEmpty(Result) then
Result := DeltaDS.FindField(FieldName).OldValue;
if Result = Null then
Result := '';
end;
end;
I have to pass a value in the stored procedure regardless, so this gives me a new value or the old value based on whether anything has changed or not. No problem with regular text fields, however, with the memo fields, if no change was made, the old value always is coming over as blank. Why?
Saving memo fields
Re: Saving memo fields
More specific information related to below, to simplify:
When TSQLQuery is simple Select (without joins), I don't have to use the BeforeUpdateRecord in Datasetprovider to applyupdates. Posts fine, and saves changes to both memo fields in table.
When TSQLQuery includes joins, then I must use BeforeUpdateRecord in Datasetprovider to post changes (using a SQLStoredProc). When I test, Oldvalue never has a value for the memo fields.
Oddly enough, when I force an error to occur, the oldvalue is available in the UpdateError handler.
When TSQLQuery is simple Select (without joins), I don't have to use the BeforeUpdateRecord in Datasetprovider to applyupdates. Posts fine, and saves changes to both memo fields in table.
When TSQLQuery includes joins, then I must use BeforeUpdateRecord in Datasetprovider to post changes (using a SQLStoredProc). When I test, Oldvalue never has a value for the memo fields.
Oddly enough, when I force an error to occur, the oldvalue is available in the UpdateError handler.
wdwhitaker wrote:I have a SQL table containing among other fields, two memo fields. I am saving records using ApplyUpdates, calling a stored procedure. I determine the old or new value of a field using the following logic:
function DeltaValueStr(DeltaDS: TDataSet; FieldName: String): Variant;
begin
with DeltaDS as TCustomClientDataSet do
begin
Result := DeltaDS.FindField(FieldName).NewValue;
if VarIsEmpty(Result) then
Result := DeltaDS.FindField(FieldName).OldValue;
if Result = Null then
Result := '';
end;
end;
I have to pass a value in the stored procedure regardless, so this gives me a new value or the old value based on whether anything has changed or not. No problem with regular text fields, however, with the memo fields, if no change was made, the old value always is coming over as blank. Why?