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 4595F53025 for ; Fri, 12 Aug 2005 12:27:38 -0300 (ADT) 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 72841-07 for ; Fri, 12 Aug 2005 15:27:36 +0000 (GMT) Received: from alvh.no-ip.org (200-85-218-206.bk4-dsl.surnet.cl [200.85.218.206]) by svr1.postgresql.org (Postfix) with ESMTP id EB34F53023 for ; Fri, 12 Aug 2005 12:27:35 -0300 (ADT) Received: by alvh.no-ip.org (Postfix, from userid 1000) id 53FCDC2D450; Fri, 12 Aug 2005 11:27:58 -0400 (CLT) Date: Fri, 12 Aug 2005 11:27:58 -0400 From: Alvaro Herrera To: santiago Cc: pgsql-sql@postgresql.org Subject: Re: catch an 'update where false' ? Message-ID: <20050812152758.GA13246@alvh.no-ip.org> Mail-Followup-To: santiago , pgsql-sql@postgresql.org References: <42FCBC94.1060403@free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42FCBC94.1060403@free.fr> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.764 tagged_above=0 required=5 tests=[AWL=0.340, DNS_FROM_RFC_ABUSE=0.374, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/70 X-Sequence-Number: 22298 On Fri, Aug 12, 2005 at 05:13:24PM +0200, santiago wrote: > hello > > I' trying to catch un update that fails to update because no row matchs > the where clause: > > for instance: > update t set c=1 where cc=2; > --and no row with cc=2 > > I would like to perform a > insert into t (c) values 1; > before the update is resolved > > I hoped a trigger before update could help me, but it seems > that if where clause evals to false, triggers are not called.. Triggers FOR EACH ROW are called once for each updated row. I think you could try with a "FOR EACH STATEMENT" trigger. -- Alvaro Herrera () "There is evil in the world. There are dark, awful things. Occasionally, we get a glimpse of them. But there are dark corners; horrors almost impossible to imagine... even in our worst nightmares." (Van Helsing, Dracula A.D. 1972)