Page 1 of 1

[D5][FB] ZQuery SubDetail and CachedUpdates fails?

Posted: 20.09.2010, 14:22
by louis
Hallo,
I have this scenario:

- ZConnection1, set AutoCommit=True;
- ZQuery1, Master, set to CachedUpdates = False;
- ZQuery2, Detail, set to:
CachedUpdates = True;
DataSource = ZQuery1;
- ZQuery3, SubDetail, set to:
CachedUpdates = True;
DataSource = ZQuery2.

All ZQuery.Connection = ZConnection1;

I applay Updates on ZQuery1.BeforePost: ZQuery2.ApplayUpdates and ZQuery3.ApplayUpdates.

When I try to post data on ZQuery2, I forget new data or modify in ZQuery3! and ZQuery3.UpdatesPendig is ever False!

To not forget data in ZQuery3 I must do:
1) modify and save data on ZQuery1
2) ZQuery1.Edit;
2) go to modify data on ZQuery3
3) ZQuery1.post.

If I do:
1) ZQuery1.Edit;
2) modify data on ZQuery1
2) modify data on ZQuery2
3) Modify data on ZQuery3
4) ZQuery1.post.

I forget all ZQuery3 modify!

Why? What I do to avoid the problem?

Thanks, Luigi

Re: [D5][FB] ZQuery SubDetail and CachedUpdates fails?

Posted: 21.09.2010, 11:00
by louis
louis wrote:I applay Updates on ZQuery1.BeforePost: ZQuery2.ApplayUpdates and ZQuery3.ApplayUpdates.
I seem to have solved the problem by reversing the instructions above with what follows:
ZQuery1.OnBeforePost: <-- Master
begin
ZQuery3.ApplayUpdates; <--SubDetail
ZQuery2.ApplayUpdates; <-- Detail
end;

But, it is the right way?

Thanks, Luigi

Re: [D5][FB] ZQuery SubDetail and CachedUpdates fails?

Posted: 02.11.2010, 18:20
by louis
louis wrote:I seem to have solved the problem by reversing the instructions above with what follows:
ZQuery1.OnBeforePost: <-- Master
begin
ZQuery3.ApplayUpdates; <--SubDetail
ZQuery2.ApplayUpdates; <-- Detail
end;
I add Foreign key constraint on Detail referring to primary key on Master.

Now when I try ZQuery3.ApplyUpdates (Detail) FireBird raise exception that not exists the key on ZQuery1 (Master) and Rollback the updates.

How is the right way to implements the scenario to have Referential Integrity?

Thanks.