From mzouroudis@idealcorp.com Thu Aug 29 16:54:18 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A6798475CF8 for ; Thu, 29 Aug 2002 12:54:18 -0400 (EDT) Received: from gateway.idealcorp.com (66-192-27-146.gen.twtelecom.net [66.192.27.146]) by postgresql.org (Postfix) with ESMTP id 0853D475C81 for ; Thu, 29 Aug 2002 12:54:18 -0400 (EDT) Received: from idealcorp.com (client07.office.ideal [192.168.1.17]) by gateway.idealcorp.com (8.12.3/8.12.3/Debian -4) with ESMTP id g7TGsNlW000837 for ; Thu, 29 Aug 2002 12:54:23 -0400 Message-ID: <3D6E51BF.1010406@idealcorp.com> Date: Thu, 29 Aug 2002 12:54:23 -0400 From: Michael Zouroudis User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: delete with referential integrity Content-Type: multipart/alternative; boundary="------------020708040802010405050907" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/354 X-Sequence-Number: 5468 --------------020708040802010405050907 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit i promise this will be my last post for a long time. my last problem on my db is caused by a trigger. i have three tables involved; assets, book_asset, and book. because of integrity constraints, i have to delete the record from book_asset, then book, and finally assets. all inserts, updates, and deletes are done through the assets table, and i have a trigger on assets that first deletes book_asset, then books, and finally assets. the problem is when it deletes assets on that third delete, it sends the db into a recursive loop(the delete on assets starts the trigger again). i am searching for an answer, but have not found one in the last hour and a half. if someone has encounted this problem before and knows a solution, i would be very grateful. the only thing i have found is a function called _funny_dup17()_, but this seems to be only for regression tests. besides from that, i am out of ideas. thanks, Mike Zouroudis Intern __________________________________________________ I.D.E.A.L. Technology Corporation - Orlando Office http://www.idealcorp.com - 407.999.9870 x14 --------------020708040802010405050907 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit i promise this will be my last post for a long time.  my last problem on my db is caused by a trigger.  i have three tables involved; assets, book_asset, and book.  because of integrity constraints, i have to delete the record from book_asset, then book, and finally assets.  all inserts, updates, and deletes are done through the assets table, and i have a trigger on assets that first deletes book_asset, then books, and finally assets.  the problem is when it deletes assets on that third delete, it sends the db into a recursive loop(the delete on assets starts the trigger again).  i am searching for an answer, but have not found one in the last hour and a half.  if someone has encounted this problem before and knows a solution, i would be very grateful.  the only thing i have found is  a function called funny_dup17(), but this seems to be only for regression tests.  besides from that, i am out of ideas.

thanks,

Mike Zouroudis
Intern
__________________________________________________
I.D.E.A.L. Technology Corporation - Orlando Office
http://www.idealcorp.com - 407.999.9870 x14

--------------020708040802010405050907-- From postgres@ragnark.vestdata.no Thu Aug 29 17:08:42 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 91590475C06 for ; Thu, 29 Aug 2002 13:08:42 -0400 (EDT) Received: from stine.vestdata.no (stine.vestdata.no [195.204.68.10]) by postgresql.org (Postfix) with ESMTP id 5A3C0475BA0 for ; Thu, 29 Aug 2002 13:08:41 -0400 (EDT) Received: (from ragnark@localhost) by stine.vestdata.no (8.11.6/8.11.2) id g7TH7tQ01106; Thu, 29 Aug 2002 19:07:55 +0200 Date: Thu, 29 Aug 2002 19:07:53 +0200 From: =?iso-8859-1?Q?Ragnar_Kj=F8rstad?= To: Michael Zouroudis Cc: pgsql-admin@postgresql.org Subject: Re: delete with referential integrity Message-ID: <20020829190753.T6228@vestdata.no> References: <3D6E51BF.1010406@idealcorp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5.1i In-Reply-To: <3D6E51BF.1010406@idealcorp.com>; from mzouroudis@idealcorp.com on Thu, Aug 29, 2002 at 12:54:23PM -0400 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/355 X-Sequence-Number: 5469 On Thu, Aug 29, 2002 at 12:54:23PM -0400, Michael Zouroudis wrote: > i promise this will be my last post for a long time. my last problem on > my db is caused by a trigger. i have three tables involved; assets, > book_asset, and book. because of integrity constraints, i have to > delete the record from book_asset, then book, and finally assets. all > inserts, updates, and deletes are done through the assets table, and i > have a trigger on assets that first deletes book_asset, then books, and > finally assets. the problem is when it deletes assets on that third > delete, it sends the db into a recursive loop(the delete on assets > starts the trigger again). i am searching for an answer, but have not > found one in the last hour and a half. if someone has encounted this > problem before and knows a solution, i would be very grateful. the only > thing i have found is a function called _funny_dup17()_, but this seems > to be only for regression tests. besides from that, i am out of ideas. You should be able to set you constraint to delete the entries in the other tables automaticly instead of refusing. Then you don't need the triggers. -- Ragnar Kjørstad From tgl@sss.pgh.pa.us Thu Aug 29 17:38:22 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34E1347672C for ; Thu, 29 Aug 2002 13:38:22 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 73388476726 for ; Thu, 29 Aug 2002 13:38:21 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g7THbVZM019788; Thu, 29 Aug 2002 13:37:31 -0400 (EDT) To: Michael Zouroudis Cc: pgsql-admin@postgresql.org Subject: Re: delete with referential integrity In-reply-to: <3D6E51BF.1010406@idealcorp.com> References: <3D6E51BF.1010406@idealcorp.com> Comments: In-reply-to Michael Zouroudis message dated "Thu, 29 Aug 2002 12:54:23 -0400" Date: Thu, 29 Aug 2002 13:37:31 -0400 Message-ID: <19787.1030642651@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/359 X-Sequence-Number: 5473 Michael Zouroudis writes: > because of integrity constraints, i have to > delete the record from book_asset, then book, and finally assets. all > inserts, updates, and deletes are done through the assets table, and i > have a trigger on assets that first deletes book_asset, then books, and > finally assets. the problem is when it deletes assets on that third > delete, it sends the db into a recursive loop(the delete on assets > starts the trigger again). Why don't you simply let the system carry on with the deletion that the trigger was called for? Seems to me the answer to the problem "my trigger is infinitely recursive" is "make your trigger not recurse". regards, tom lane