From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Justin <zzzzz(dot)graf(at)gmail(dot)com> |
Cc: | DAVID ROTH <adaptron(at)comcast(dot)net>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Trigger questions |
Date: | 2023-05-04 14:42:33 |
Message-ID: | CAKFQuwbXO=WTBVrkZCe25AR+bphP+_L6xx7rJWLOdST70hGt8A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, May 4, 2023 at 7:04 AM Justin <zzzzz(dot)graf(at)gmail(dot)com> wrote:
>
>
> On Thu, May 4, 2023 at 9:49 AM DAVID ROTH <adaptron(at)comcast(dot)net> wrote:
>
>> 1) Can I create a trigger on a view?
>> 2) Do triggers cascade?
>>
>> Say I have an insert trigger on a table.
>> And, I have an insert trigger on a view that references this table
>> If I do an insert on the view, will both triggers fire?
>>
>
> Can not have triggers on Views, Views use RULES which are DO INSTEAD.
> https://www.postgresql.org/docs/current/rules.html
>
Our users need not care or even know about this particular implementation
detail of views. For them, views are a fundamental concept.
The description of create trigger makes is perfectly clear that views are a
valid "table-like" target for a trigger.
> CREATE TRIGGER creates a new trigger. CREATE OR REPLACE TRIGGER will
either create a new trigger, or replace an existing trigger. The trigger
will be associated with the specified table, view, or foreign table and
will execute the specified function function_name when certain operations
are performed on that table.
https://www.postgresql.org/docs/current/sql-createtrigger.html
Depending on the view definition, the need for a trigger may be removed
since some views are auto-updatable.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Nagendra Mahesh (namahesh) | 2023-05-04 15:01:46 | Re: Invoking SQL function while doing CREATE OR REPLACE on it |
Previous Message | Adrian Klaver | 2023-05-04 14:30:56 | Re: Trigger questions |