Re: Combining insert rules on views with functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bastiaan Olij <bastiaan(at)basenlily(dot)me>
Cc: pgsql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Combining insert rules on views with functions
Date: 2015-09-17 03:46:46
Message-ID: 23135.1442461606@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Bastiaan Olij <bastiaan(at)basenlily(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2015-09-17 04:14:04 Re: Combining insert rules on views with functions
Previous Message Bastiaan Olij 2015-09-17 03:21:46 Combining insert rules on views with functions