Re: [GENERAL] CREATE RULE with WHERE clause

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: [GENERAL] CREATE RULE with WHERE clause
Дата
Msg-id 730028.97435.qm@web31812.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на CREATE RULE with WHERE clause  (Ranieri Mazili <ranieri.oliveira@terra.com.br>)
Список pgsql-sql
> 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.

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

Предыдущее
От: Sean Davis
Дата:
Сообщение: Re: [NOVICE] JOIN
Следующее
От: "Loredana Curugiu"
Дата:
Сообщение: Re: JOIN