Re: Views: having a rule call a function vs. using a before trigger - Mailing list pgsql-general

From Ken Downs
Subject Re: Views: having a rule call a function vs. using a before trigger
Date
Msg-id jdtinh.7kvha9@dhost2.secdat.com
Whole thread Raw
In response to Views: having a rule call a function vs. using a before trigger  ("Karl O. Pinc" <kop@meme.com>)
List pgsql-general
"Karl O. Pinc" <kop@meme.com> wrote:

> Hi,
>
> Postgresql 8.1.
>
> I'm trying to come up with a generic way
> of inserting into a view, particularly regards
> error testing and the generation of complicated
> foreign keys. I don't seem to be having much luck.
>
> (I also want to update and delete, but haven't gotten
> that far.)

Before I mount too much of a reply, may I ask in particular
why you are targeting views? Reason I ask is that I've gone
through the same
process and have worked out a general
approach to implementing all biz logic
in triggers.

However, as the biz logic is defined in terms of tables, we
attached all logic always to tables. When for whatever
reason the user is
going through a view, the rule sends it
back to the base table where the biz
logic takes care of it
there.

This avoids attempting to redefine or
recast the rules in
the context of any particular view.

So that is why I am
asking why in particular you
are asking about views.


>
> I thought that, for inserts at least, I could write
> a rule that called a function and have the function
> do anything complicated, raise exceptions, etc.
> But I get the error message shown below.
>

pgsql-general by date:

Previous
From: "Michael Nolan"
Date:
Subject: How can you tell if a function is immutable from psql?
Next
From: cedric
Date:
Subject: Re: Slow running to_tsvector (tsearch2 in PG 8.2.3)