Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Value x OldValue
Tue, Nov 7 2006 6:16 AMPermanent Link

"Jose Eduardo Helminsky"
Hi everyone

I´ve changed my THProTable (inherited from TDBISamTable) to create a new
method called Modified. I want to use it to alert the users when they change
some values from current record and apply cancel button. This method is
simple but works like expected except from one thing: When the state of
table is dsBrowse and I call this method the value of the "OldValue"
property is always NULL.

It is by design or this is a bug in DB.PAS ?

My code:

function THProTable.Modified: Boolean;
var nI: Integer;
begin
    Result := False;
    for nI := 0 to Fields.Count-1 do begin
       if Fields[nI].OldValue <> Fields[nI].Value then begin
          Result := True;
          break;
       end;
    end;
end;

IMO when the state of a dataset is dsBrowse then the OldValue should be the
same as Value. Or am I wrong ?

Eduardo

Tue, Nov 7 2006 8:17 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose


My guess is its by design - if the table is in dsBrowse mode then any changes have been committed therefore there is no old value.

It makes sense unless you expect the database to keep a record of all the changes.

Roy Lambert
Tue, Nov 7 2006 9:00 AMPermanent Link

"Jose Eduardo Helminsky"
Roy

I understand your point but at least for me the OldValue and Value in this
state of the dataset should be the same instead of OldValue = null.

I can live with this behavior but...

Thanks for your comment

Eduardo

Tue, Nov 7 2006 9:03 AMPermanent Link

"David Farrell-Garcia"
Jose Eduardo Helminsky wrote:

> IMO when the state of a dataset is dsBrowse then the OldValue should
> be the same as Value. Or am I wrong ?
>
> Eduardo

Think of the oldvalue as a delta.  It only contains a value if the
field is modifed, otherwise it is null.  Once committed, it is null
once again. You would be better coding it as:

if oldvalue <> null then ....

When using oldvalues or deltas you should always check for null values.

--
David Farrell-Garcia
Whidbey Island Software, LLC
Tue, Nov 7 2006 9:04 AMPermanent Link

"David Farrell-Garcia"
Jose Eduardo Helminsky wrote:

> Roy
>
> I understand your point but at least for me the OldValue and Value in
> this state of the dataset should be the same instead of OldValue =
> null.
>
> I can live with this behavior but...
>
> Thanks for your comment
>
> Eduardo

That is pretty much the way it is anywhere.  ClientDataSets are the
same.  You must check OldValue before updates are actually committed.

--
David Farrell-Garcia
Whidbey Island Software, LLC
Tue, Nov 7 2006 5:10 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Eduardo,

<< It is by design or this is a bug in DB.PAS ? >>

By design.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image