Received: from lh00.opsion.fr (lh00.opsion.fr [212.73.208.226]) by postgresql.org (8.11.3/8.11.4) with SMTP id fAK3o7m01639 for ; Mon, 19 Nov 2001 22:50:07 -0500 (EST) (envelope-from cnliou@eurosport.com) Received: from 10.1.1.8 [10.1.1.8] by lh00.opsion.fr; Tue, 20 Nov 2001 03:50:03 GMT Send-By: 203.66.130.107 with Mozilla/4.78 [en] (Win95; U) To: Subject: Re: Foreign Key Constraint Deletion Order From: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Date: Tue, 20 Nov 2001 03:50:03 GMT Message-id: <200111200350.0341@lh00.opsion.fr> Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by postgresql.org id fAK3puL01719 X-Archive-Number: 200111/276 X-Sequence-Number: 5658 Thanks again! Stephan, > I think you can do this as part of a trigger on PurchaseMaster and > something that doesn't do the subtraction if the subselect returns > a NULL in the detail trigger (or subtracts 0), not as pretty, but > it should function. The master trigger would subtract as necessary > for the details for the user. This is really a pain though it works. Since delete from PurchaseMaster and PurchaseDetail are both possible, two subtraction trigger functions must be written for PurchaseMaster and PurchaseDetail, respectively. It also seems unwise not to use the powerful-but-easy-to-use RI capability (on delete cascade on update cascade) but to implement it with my own trigger to be fired by PurchaseMaster. If the delete was always done on PurchaseDetail before PurchaseMaster, then one subtraction function for PurchaseDetail along with the RI would settle down everything. Am I asking for too much, or RI and triggers were not designed for operations like this example in the first place? CN -------------------------------------------------------- You too can have your own email address from Eurosport. http://www.eurosport.com