Re: deleting from a view

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: shawn everett <everett(at)pgweb(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: deleting from a view
Date: 2000-10-17 23:43:32
Message-ID: 2947.971826212@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

shawn everett <everett(at)pgweb(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Mount 2000-10-17 23:54:57 Re: Error building JDBC Driver
Previous Message Stephan Szabo 2000-10-17 23:37:52 Re: deleting from a view