Re: deleting from a view - Mailing list pgsql-general

From Tom Lane
Subject Re: deleting from a view
Date
Msg-id 2947.971826212@sss.pgh.pa.us
Whole thread Raw
In response to deleting from a view  (shawn everett <everett@pgweb.com>)
List pgsql-general
shawn everett <everett@pgweb.com> writes:
> Should I use a trigger or a rule?  If I use a trigger how should it be
> written.  If I use a rule how do I put two delete statements in it.

You can't use a trigger, because a trigger is fired at the point where
a physical tuple is about to be inserted/deleted/updated.  The view has
no physical tuples, therefore nothing to fire a trigger on.

The problem with the rule, as you guessed, is that once you delete from
the first table there are no longer any matching tuples in the view
(which is what OLD is referring to), so second delete doesn't find any
matches.  Perhaps Jan Wieck can think of a solution ... I'm not sure
how to do it.

            regards, tom lane

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: deleting from a view
Next
From: Peter Mount
Date:
Subject: Re: Error building JDBC Driver