Lazarus

Free Pascal => Database => Topic started by: Soner on December 10, 2018, 01:28:37 pm

Title: SQLDB, tfield.oldvalue shows value from current row not activerecord, bug?
Post by: Soner on December 10, 2018, 01:28:37 pm
I am using TDataset.ActiveRecord property.

When one field is not changed, then field.oldvalue shows the value from current row not from active record.
Only when the field value changed then it show right value.
Is this bug?

Look at my comments on screenshots.

(I had similar error on zeoscomponents.
http://zeoslib.sourceforge.net/viewtopic.php?f=28&t=84847 (http://zeoslib.sourceforge.net/viewtopic.php?f=28&t=84847)
)
Title: Re: SQLDB, tfield.oldvalue shows value from current row not activerecord, bug?
Post by: Soner on December 10, 2018, 01:29:23 pm
this is example project:
Title: Re: SQLDB, tfield.oldvalue shows value from current row not activerecord, bug?
Post by: Soner on December 12, 2018, 09:46:14 am
Is nobody using tfield.olvalue, tdataset.activerecord in his programs?
Title: Re: SQLDB, tfield.oldvalue shows value from current row not activerecord, bug?
Post by: Soner on December 12, 2018, 02:19:08 pm
Yes it is bug, It should show correct value or nothing.I reported it here
https://bugs.freepascal.org/view.php?id=34694 (https://bugs.freepascal.org/view.php?id=34694)

(PS: In example from above save-button does not work. It is half ported zeos example.)
Title: Re: SQLDB, tfield.oldvalue shows value from current row not activerecord, bug?
Post by: valdir.marcos on February 22, 2019, 11:08:02 pm
I am using TDataset.ActiveRecord property.

When one field is not changed, then field.oldvalue shows the value from current row not from active record.
Only when the field value changed then it show right value.
Is this bug?

Look at my comments on screenshots.

(I had similar error on zeoscomponents.
http://zeoslib.sourceforge.net/viewtopic.php?f=28&t=84847 (http://zeoslib.sourceforge.net/viewtopic.php?f=28&t=84847)
)
I don't use TDataset.ActiveRecord, but a similar approach related to OldValue x NewValue could be:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   IBConnection1.Connected := False;
  4.   IBConnection1.HostName := 'your server/3050';
  5.   IBConnection1.DatabaseName := 'your database';
  6.   IBConnection1.UserName := 'your user';
  7.   IBConnection1.Password := 'your password';
  8.   IBConnection1.CharSet := 'UTF8';
  9.   IBConnection1.Connected := True;
  10.  
  11.   SQLQuery1.Close;
  12.   SQLQuery1.SQL.Text := 'Select Field2 From Table1 Where Field1 = 1;';
  13.   SQLQuery1.Open;
  14.   SQLQuery1.Edit;
  15.   SQLQuery1.FieldByName('Field2').AsString := 'new value';
  16.   ShowMessage('OldValue: ' + SQLQuery1.FieldByName('Field2').OldValue + LineEnding +
  17.               'NewValue: ' + SQLQuery1.FieldByName('Field2').NewValue);
  18.   SQLQuery1.CancelUpdates;
  19.   SQLQuery1.Cancel;
  20.   SQLTransaction1.Rollback ;
  21.   IBConnection1.Connected := False;
  22. end;
Title: Re: SQLDB, tfield.oldvalue shows value from current row not activerecord, bug?
Post by: Soner on March 01, 2019, 06:51:57 pm
Thanks for your effort, but I need it without changing Cursor position (TDBGrid).
TinyPortal © 2005-2018