Saving memo fields

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
wdwhitaker

Saving memo fields

Post by wdwhitaker » Fri 08 Jul 2005 16:15

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?

wdwhitaker

Re: Saving memo fields

Post by wdwhitaker » Sat 09 Jul 2005 13:39

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.


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?

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 11 Jul 2005 08:40

It is a specific of storing BLOB fields in DataSet not related to DbxSda.

Post Reply