CachedUpdates on cascade delete

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

cazanvova
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 27.01.2009, 10:49

CachedUpdates on cascade delete

Postby cazanvova » 28.01.2009, 14:33

Helo! sory my english! :(
PLEASE HELP ME!!!
have3 table tbl1(CachedUpdates=true) , tbl2(CachedUpdates=true) , tbl3(CachedUpdates=true)

field tbl1: id,a
field tbl2: id,id1,b
field tbl3: id1,id2,c

relation
tbl1.id -> tbl2.id
tbl2.id1 -> tbl3.id1

id,id1,id2: triger
(CachedUpdates=true)
on button OK do ApplyUpdates and ComitUpdates (for tbl1,tbl2,tbl3).but if delete record from tbl2 and after that do ApplyUpdates, - have

SQL Error: violation of FOREIGN KEY constraint "TBL2_TBL3_FK" on table "TBL3" Foreign key reference target does not exist. Error Code: -530. violation of FOREIGN KEY constraint "" The SQL: INSERT INTO TBL3 (ID1,ID2,C) VALUES (?,?,?);

use firebird 2.0 Zeos 6.6.3!!!

seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Postby seawolf » 31.01.2009, 11:38

This problem is not related to Zeos, but how you db was structured.

I mean if TBL3.id1 depends on TBL2.id1 it is obvious that if you delete a row TBL2.id1 you have to delete the corrisponding row TBL3.id1.

So you can do:
- delete row TBL3.id1 before deleting row TBL2.id1 separately
or
- do a stored procedure where you delete both rows

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 31.01.2009, 13:07

Or you could add an on cascade rule to yor foreign key

Code: Select all

ALTER TABLE INVOICE_SCHEDULE_DATES ADD
FOREIGN KEY (INV_SCHED_ID) REFERENCES INVOICE_SCHEDULE
(INV_SCHED_ID)
ON DELETE CASCADE
ON UPDATE CASCADE;


Mark
Image


Return to “6.5.1 (alpha) - 6.6.x (beta)”

Who is online

Users browsing this forum: No registered users and 1 guest