Search Postgresql Archives

Re: CREATE RULE with WHERE clause

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux