On Wed, 06 Jan 2010 09:39:45 -0600,
Seb <splu...@gmail.com> wrote:

> Would this express the intention any better?

> CREATE RULE footwear_nothing_upd AS
>     ON UPDATE TO footwear DO INSTEAD NOTHING;
> CREATE RULE footwear_newshoelaces_upd AS
>     ON UPDATE TO footwear
>     WHERE NOT EXISTS (SELECT sh_id FROM shoelaces WHERE 
> NEW.sh_id=shoelaces.sh_id)
>     DO
> INSERT INTO shoelaces (sh_id, sl_name)
>     VALUES(NEW.sh_id, NEW.sl_name);

Adding to my confusion here, is the fact that the rule above seems to
work well, even though the docs say:

---<--------------------cut here---------------start------------------->---
condition

 Any SQL conditional expression (returning boolean). The condition
 expression cannot refer to any tables except NEW and OLD, and cannot
 contain aggregate functions.
---<--------------------cut here---------------end--------------------->---

So the WHERE condition in the rule above should not be allowed since it
does reference a table other than NEW and OLD in the EXISTS statement.
Any enlightening comments appreciated.


-- 
Seb


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to