Re: NEW variable values in actions in rules

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: NEW variable values in actions in rules
Дата
Msg-id 6358.1138835696@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: NEW variable values in actions in rules  ("Ken Winter" <ken@sunward.org>)
Ответы Why does an ON SELECT rule have to be named "_RETURN"?  ("Ken Winter" <ken@sunward.org>)
Список pgsql-general
"Ken Winter" <ken@sunward.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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Ken Winter"
Дата:
Сообщение: Re: NEW variable values in actions in rules
Следующее
От: Bob Pawley
Дата:
Сообщение: Stack Depth