Re: Rule causes baffling error - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Rule causes baffling error
Date
Msg-id 43A67879.3050003@archonet.com
Whole thread Raw
In response to Rule causes baffling error  ("Ken Winter" <ken@sunward.org>)
Responses Re: Rule causes baffling error  ("Ken Winter" <ken@sunward.org>)
List pgsql-sql
Ken Winter wrote:
> This rule is supposed to (1) cause an update directed to the view
> "my_data_now" to be made to the underlying table "my_data", (2) reset the
> "effective_date_and_time" of that row to 'now', (3) insert a record
> containing the old values into "my_data", and (4) expire that "old" record
> by setting its "expiration_date_and_time" to 'now'.

I think you want a trigger rather than a rule.

Rules rewrite the query structure, triggers let you deal with values on 
a row-by-row basis (for row-level triggers).

--   Richard Huxton  Archonet Ltd


pgsql-sql by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Does VACUUM reorder tables on clustered indices
Next
From: "Lane Van Ingen"
Date:
Subject: How to Force Transactions to Process Serially on A Table