Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j9rx3-0000ne-0I for pgsql-general@arkaria.postgresql.org; Thu, 05 Mar 2020 14:58:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9rx1-0007SM-RX for pgsql-general@arkaria.postgresql.org; Thu, 05 Mar 2020 14:58:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j9rx1-0007SE-EP for pgsql-general@lists.postgresql.org; Thu, 05 Mar 2020 14:58:15 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9rwz-0008Dp-3C for pgsql-general@lists.postgresql.org; Thu, 05 Mar 2020 14:58:14 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 48YDQD0600zwbr for ; Thu, 5 Mar 2020 09:58:11 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 17622) id 48YDQC5Z2pzfYm; Thu, 5 Mar 2020 09:58:11 -0500 (EST) Date: Thu, 5 Mar 2020 09:58:11 -0500 From: stan To: pgsql-general@lists.postgresql.org Subject: A question about the number of times a trigger will fire Message-ID: <20200305145811.GA17538@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Editor: gVim List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I am in the process of trying to set up a function.trigger pair to create functionally an updateable view. I would think that the trigger would fire the number of times that the calling statement's WHERE clause seceded. Is this incorrect> I have a view called purchase_view, one of the tables in it's join is a table called bom_item. I have defined this trigger: REATE TRIGGER test_v_trig INSTEAD OF INSERT OR UPDATE ON purchase_view FOR EACH ROW EXECUTE PROCEDURE v_trig_test(); Prior to firing this trigger this query select count(*) FROM purchase_view WHERE proj_no = 3124 AND m_name = 'Mencom' ; returns 11 The resultant statement generated by the function called by this trigger is: UPDATE BOM_ITEM SET cost_per_unit = 23.45 , qty = 12345.00 Which in retrospect dies not do what I had in mind :-) So, it appears that I need to create a WHERE clause for the resultant statement. But I do not see how the function has enough data to use to create this where clause. What am I missing, here? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin