Re: Combining insert rules on views with functions - Mailing list pgsql-novice

From Tom Lane
Subject Re: Combining insert rules on views with functions
Date
Msg-id 23135.1442461606@sss.pgh.pa.us
Whole thread Raw
In response to Combining insert rules on views with functions  (Bastiaan Olij <bastiaan@basenlily.me>)
List pgsql-novice
Bastiaan Olij <bastiaan@basenlily.me> writes:
> I've got a situation where I'm adding an insert rule to a view but the
> work I need to do in order to insert the required data doesn't fit well
> in a simple query rewrite (I need to calculate a few things before I'm
> ready to do my insert).

> Because of this I've moved the actual insert code into a function which
> in looks sort of like this:

... umm, have you considered using a BEFORE INSERT trigger instead?
AFAICT, what you really want here is to compute some derived column
values before the row gets stored, and a trigger would handle that
nicely without any need to abuse semantics.

            regards, tom lane


pgsql-novice by date:

Previous
From: Bastiaan Olij
Date:
Subject: Combining insert rules on views with functions
Next
From: Tom Lane
Date:
Subject: Re: Combining insert rules on views with functions