X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E5A7A9FB1CD for ; Sun, 17 Sep 2006 11:37:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 20379-10 for ; Sun, 17 Sep 2006 11:36:57 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 959DF9FA47B for ; Sun, 17 Sep 2006 11:36:56 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id k8HEal4X069130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 17 Sep 2006 08:36:50 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id k8HEalTi096942; Sun, 17 Sep 2006 08:36:47 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id k8HEakgv096941; Sun, 17 Sep 2006 08:36:46 -0600 (MDT) (envelope-from mfuhr) Date: Sun, 17 Sep 2006 08:36:46 -0600 From: Michael Fuhr To: Joost Kraaijeveld Cc: pgsql-sql@postgresql.org Subject: Re: Transactional behaviour with trigger Message-ID: <20060917143646.GA96792@winnie.fuhr.org> References: <1158496330.6107.17.camel@panoramix> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1158496330.6107.17.camel@panoramix> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.151 tagged_above=0 required=5 tests=AWL, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/117 X-Sequence-Number: 26328 On Sun, Sep 17, 2006 at 02:32:10PM +0200, Joost Kraaijeveld wrote: > For the contactaddress I also have a trigger(function) that should > update the record in the third table with the additional info of the > contactaddress: > > .... > SELECT INTO customer_record objectid FROM prototype.customers WHERE contactaddress = NEW.objectid; > IF customer_record.objectid IS NOT NULL THEN > UPDATE customeraddress set zipcode = NEW.zipcode, city = NEW.city, housenumber = NEW.housenumber , address = NEW.objectid > WHERE customer = customer_record.objectid; > > This last trigger is executed but customer_record.objectid seems to be > always NULL as if the the customer record is not visible. Is that > correct or is there something wrong with the SQl above? Where does prototype.customers fit in? Are you sure it has a row that matches the WHERE clause? Where would that row have come from? Is there a reason you're maintaining customeraddress as a materialized view rather than as a "real" view? -- Michael Fuhr