From: stan <stanb@panix.com>
To: pgsql-general@lists.postgresql.org
Subject: A question about the number of times a trigger will fire
Date: Thu, 5 Mar 2020 09:58:11 -0500
Message-ID: <20200305145811.GA17538@panix.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: stanb@panix.com
Subject: Re: A question about the number of times a trigger will fire
In-Reply-To: <20200305145811.GA17538@panix.com>
References: <20200305145811.GA17538@panix.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox