Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu> writes:
> foo=# CREATE TABLE a(foo integer);
> CREATE
> foo=# CREATE TABLE b(foo integer);
> CREATE
> foo=# CREATE VIEW c AS SELECT foo FROM a;
> CREATE
> foo=# CREATE RULE d AS ON INSERT TO c WHERE new.foo=5 DO INSTEAD SELECT foo FROM b;
> CREATE
> foo=# INSERT INTO c VALUES (5);
> ERROR: Cannot insert into a view without an appropriate rule
You didn't provide a rule covering the new.foo<>5 case.
In practice, you *must* have an unconditional INSTEAD rule present for
any view operation you want to allow. It can be DO INSTEAD NOTHING,
and then you can do all your useful work in conditional rules, but the
unconditional rule must be there. Else the system thinks that perhaps
the insert into the view would really happen.
regards, tom lane