TZQuery 'NewValue' and 'OldValue'

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

TZQuery 'NewValue' and 'OldValue'

Post by elidorio2 »

Hello Guys,

I am in need of aid, how to use the function in TZQuery 'NewValue' and 'OldValue'. I need to upgrade the value is changed.
Thanks for the help.

Edson
cacofony
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 06.12.2006, 15:24
Location: Perth - Western Australia
Contact:

Re: TZQuery 'NewValue' and 'OldValue'

Post by cacofony »

Could you clarify further? How to use NewValue and OldValue?

http://stackoverflow.com/questions/1971 ... as-streams


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;
elidorio2
Expert Boarder
Expert Boarder
Posts: 159
Joined: 20.08.2006, 05:37
Location: Tapejara -Pr
Contact:

Re: TZQuery 'NewValue' and 'OldValue'

Post by elidorio2 »

Had tried to do this way In Event "BeforPost" the query:
Note: I need to compare a value if the value changes I perform a procedure:

if qryForm.State in [dsEdit] then
qryFormvlr_serv.OldValue;

if qryFormvlr_serv.OldValue <> qryFormvlr_serv.NewValue then
begin
verifica_status;
end;
cacofony
Fresh Boarder
Fresh Boarder
Posts: 16
Joined: 06.12.2006, 15:24
Location: Perth - Western Australia
Contact:

Re: TZQuery 'NewValue' and 'OldValue'

Post by cacofony »

I use something like this, ZQuery, MySQL

Code: Select all

OnBeforePost
var
OldValue : variant;
begin
if Self.State in [dsEdit] then
    begin
      if not FieldByName('taskstatusid').IsNull then
      begin
      OldValue := FieldByName('taskstatusid').OldValue;
       if VarIsOrdinal(OldValue) then
        begin
          if  FieldByName('taskstatusid').AsInteger <> VarAsType(OldValue, VarType(OldValue)) then
        begin
          // Status has changed.
        end;
        end;
     end;
end;
Post Reply