On Wed, 2002-09-18 at 17:08, Anto Prijosoesilo wrote: > I was afraid that you're going to say that (use > triggers) :-). > > I'm trying _not_ to use triggers because rules are > more maintainable than triggers here in my > environment. At least with rules someone who knows SQL > would be able to maintain it with just a little extra > training. > > The PostgreSQL 7.2 Reference Manual, in the section > for CREATE RULE seems to imply that the rules are > executed per row of the target table. I'm referring to > paragraph 2 of the description.
Read the last paragraph of that section: It is important to realize that a rule is really a query transformation mechanism, or query macro. The entire query is processed to convert it into a series of queries that include the rule actions. This occurs before evaluation of the query starts. So, conditional rules are handled by adding the rule condition to the WHERE clause of the action(s) derived from the rule. The above description of a rule as an operation that executes for each row is thus somewhat misleading. If you actually want an operation that fires independently for each physical row, you probably want to use a trigger not a rule. Rules are most useful for situations that call for transforming entire queries independently of the specific data being handled. Not that the description is obvious, but it's there. Perhaps you know of a better way (place) to state this? -- Rod Taylor ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster