X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A46B13A3C0C for ; Tue, 26 Oct 2004 18:22:01 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50878-06 for ; Tue, 26 Oct 2004 17:21:53 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 5D08E3A3B1F for ; Tue, 26 Oct 2004 18:21:51 +0100 (BST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i9QHLoJ7052536 for ; Tue, 26 Oct 2004 17:21:50 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i9QH028A044666 for pgsql-sql@postgresql.org; Tue, 26 Oct 2004 17:00:02 GMT From: jboes@nexcerpt.com (Jeff Boes) X-Newsgroups: comp.databases.postgresql.sql Subject: How to recognize trigger-inserted rows? Date: 26 Oct 2004 10:00:01 -0700 Organization: http://groups.google.com Lines: 18 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/185 X-Sequence-Number: 19288 I have a table with an INSERT/UPDATE/DELETE statement trigger. The trigger's action is to insert "jobs" into a queue noting that the table has changed. A number of other tables have FK relationships with this table, and they have their own statement triggers that fire on DELETE. When I delete a number of rows from the first table, the cascading deletes into the other tables generate a rather large number of trigger-fires, so I end up with way too many rows in the queue-table. What I would like to do is, within the transaction doing the top-level delete, examine the queue-table for duplicate rows and remove those, since they are extraneous. Ideally I would look for rows that have the same transaction ID, but I'm having trouble determining what the current ID is. I'm using Pg 7.4.