"Dean Gibson (DB Administrator)" <postgresql@ultimeth.com> writes:
> So, I tried:
> CREATE RULE _update AS ON UPDATE TO public.yyy DO INSTEAD
> (DELETE FROM private.zzz WHERE key_field = OLD.key_field;
> INSERT INTO private.zzz VALUES( NEW.*) );
Nope, won't work, standard gotcha for rules newbies. As soon as you
delete in the first command, the row no longer exists in the view,
and "new.*" is just a macro for a view reference.
AFAIK there really isn't any way to do it except
ON UPDATE DO INSTEADUPDATE private.zzz SET f1 = new.f1, f2 = new.f2, ...WHERE key_field = old.key_field;
BTW, you should also consider adding RETURNING clauses to these
rules so that UPDATE RETURNING &etc will work on the views.
Here at least you can use "RETURNING *" ...
regards, tom lane