From: Richard Broersma Jr <rabroersma@yahoo.com>
To: Ranieri Mazili <ranieri.oliveira@terra.com.br>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
Subject: Re: CREATE RULE with WHERE clause
Date: Tue, 5 Jun 2007 07:07:29 -0700 (PDT)
Message-ID: <730028.97435.qm@web31812.mail.mud.yahoo.com> (raw)
In-Reply-To: <4665611F.9020500@terra.com.br>
> CREATE RULE rule_role_sul AS
> ON SELECT TO t1 WHERE roles = 'role_sul'
> DO INSTEAD
> SELECT field1, field2 FROM t2;
>
> CREATE RULE rule_role_sul AS
> ON SELECT TO t1 WHERE roles = 'role_norte'
> DO INSTEAD
> SELECT field3, field4 FROM t2;
From: http://www.postgresql.org/docs/8.2/interactive/sql-createrule.html
...
WHERE condition
Any SQL conditional expression (returning boolean). The condition expression may not refer to any
tables except NEW and OLD, and may not contain aggregate functions.
...
This statement to me implies that only ON {INSERT | UPDATE | DELETE } actions can use the WHERE
syntax since only inserts, updates, and deletes product the NEW.* and OLD.* tables.
Also, NEW.* and OLD.* only apply to a single tuple in the view that is being changed. So I do not
think you can not use the where syntax in your query since it does not and cannot reference a NEW
or OLD tuple.
Regards,
Richard Broersma Jr.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rabroersma@yahoo.com, ranieri.oliveira@terra.com.br, pgsql-general@postgresql.org
Subject: Re: CREATE RULE with WHERE clause
In-Reply-To: <730028.97435.qm@web31812.mail.mud.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox