Re: Problems using a rule with the WHERE clause

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Problems using a rule with the WHERE clause
Дата
Msg-id 16743.993492071@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Problems using a rule with the WHERE clause  (Luis Sousa <llsousa@ualg.pt>)
Список pgsql-sql
Luis Sousa <llsousa@ualg.pt> writes:
> CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno"
>  WHERE OLD.idpessoal != 0
>  DO INSTEAD (
>  ...

> When I execute the INSERT into de view docentesturno I got the message:
>             ERROR:  Cannot update a view without an appropriate rule

You failed to supply a rule covering the case OLD.idpessoal = 0.

More specifically, you *must* supply an unconditional INSTEAD rule to
replace the attempt to insert/update in the view.  Possibly what you
want is

CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno"
WHERE OLD.idpessoal != 0
DO ( ... );

CREATE RULE "updateturnodocente_default" AS ON UPDATE TO "docentesturno"
DO INSTEAD NOTHING;

Here, the unconditional rule always fires, and the conditional one fires
only when its condition is true.
        regards, tom lane


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

Предыдущее
От: Wei Weng
Дата:
Сообщение: control structure in a transaction block?
Следующее
От: "William Herring"
Дата:
Сообщение: select with multiple occurences in same table