Re: NEW variable values in actions in rules

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ken Winter" <ken(at)sunward(dot)org>
Cc: "'PostgreSQL pg-general List'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: NEW variable values in actions in rules
Date: 2006-02-01 23:14:56
Message-ID: 6358.1138835696@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Ken Winter" <ken(at)sunward(dot)org> writes:
> I have a table "person_h" with a not-null column "effective_date_and_time"
> that defaults to CURRENT_TIMESTAMP.

> I have a view "person" with the following rule defined on it:

> CREATE RULE on_insert AS
> ON INSERT TO person
> DO INSTEAD (
> INSERT INTO person_h (person_id, ...
> effective_date_and_time, ...)

You need to provide a column default on the view; the one on the
underlying table would only enter into the picture if the "INSERT INTO
person_h" command in the rule omitted specifying effective_date_and_time,
which it does not.

Use ALTER TABLE person ALTER COLUMN ... SET DEFAULT ... to attach a
default to the view.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Pawley 2006-02-01 23:44:28 Stack Depth
Previous Message Michelle Konzack 2006-02-01 23:08:28 Re: Alternative to knoda, kexi and rekall?