Re: Why can't I put a BEFORE EACH ROW trigger on a view? - Mailing list pgsql-general

From Karl O. Pinc
Subject Re: Why can't I put a BEFORE EACH ROW trigger on a view?
Date
Msg-id 1172366424l.30468l.9l@mofo
Whole thread Raw
In response to Re: Why can't I put a BEFORE EACH ROW trigger on a view?  ("Webb Sprague" <webb.sprague@gmail.com>)
List pgsql-general
On 02/24/2007 06:55:45 PM, Webb Sprague wrote:
> I also think that a view is supposed to be just that -- a *view* of
> underlying data, which in no way modifies the data.  I don't know much
> about the design ideas behind  SQL, but I think this view of views
> (haha) is an underlying assumption.  If you are modifying data when
> you do a select on a view, you are probably not using SQL the way it
> was intended (not that that is a bad thing, but ...)

The postgresql docs say something like: Having lots of views
is the mark of good database design.

That's because views present the same data in various ways,
to different users as each user thinks of the data.  In general,
they allow good db design, and in a well designed db will
be incomprensibe to the average user, partly because it contains lots
of foreign keys to manage 1-to-many relationships.  If it
makes sense to make a view so the user can see the data
in a form they can understand, then it makes sense to
allow the user to update the same view of the data.

> Postgresql has "rules" which I *think* can rewrite select statements.
> Rules are kind of a pain, but maybe what you want.

You can't rewrite select statments.  That's where I started.
Trying to do so turns your table into a view, which then
can't have triggers.

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                  -- Robert A. Heinlein


pgsql-general by date:

Previous
From: "Karl O. Pinc"
Date:
Subject: Re: Why can't I put a BEFORE EACH ROW trigger on a view?
Next
From: Tom Lane
Date:
Subject: Re: Why can't I put a BEFORE EACH ROW trigger on a view?