Page 1 of 1

CommitUpdates setting status of inserted record as deleted

Posted: 14.07.2016, 19:50
by bsoft
When using a ZQuery with CachedUpdates = True and executing ApplyUpdates followed by CommitUpdates, the record's UpdateStatus is set to usDeleted, which generates an Error when trying to Edit the Record.

ZConnection properties are AutoCommit = True and TransactionIsolation = tiReadCommited. Zeos version 7.1.4 and Firebird Datasbase.

Example:

qryTest.Open;
qryTest.Append;
// set field values
qryTest.Post;
qryTest.ApplyUpdates;
qryTest.CommitUpdates; // qryTest.UpdateStatus = usDeleted
qryTest.Edit;
//set field values
qryTest.Post; //Exception 'Cannot update a deleted row'

It seems to me that the error is caused by TZAbstractDataset.CommitUpdates calling CachedResultSet.CancelUpdates, which executes this code:

if CurrentRow.UpdateType = utInserted then
InitialRow.UpdateType := utDeleted;

Is this intended? Shouldn't CommitUpdates call DisposeCachedUpdates?

Zeos 7.2 should have the same issue, although I didn't test it, only looked at the source code.

Thanks.

Re: CommitUpdates setting status of inserted record as deleted

Posted: 29.07.2016, 10:26
by marsupilami
Hello bsoft,

could you try to build a small test case? Just a database script and a small Delphi or Lazarus project? That helps in tracking things down.
With best regards,

Jan

Re: CommitUpdates setting status of inserted record as deleted

Posted: 05.08.2016, 16:26
by Fr0sT
The same thing I reported in SVN tickets

Re: CommitUpdates setting status of inserted record as deleted

Posted: 05.08.2016, 20:05
by bsoft
marsupilami wrote:Hello bsoft,

could you try to build a small test case? Just a database script and a small Delphi or Lazarus project? That helps in tracking things down.
With best regards,

Jan
Here you go.

Thanks