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

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

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

Post 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
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

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

Post 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
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

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

Post 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.
Post Reply