Subject: multiple actions

From: [email-masked] (Raymond D. Frost)
Date: Thu, 6 Feb 92 22:35:51 -0800

Is there a way to have multiple actions take place as the result of a
single rule firing?  For example:

define rule foo_bar is
on append to dog
where tail = "wagging"
do instead [ append cat (tail = "swishing") append trace (rule_fired =
"foo_bar") ] 

What I'm really after is a way to trace the process of backward
chaining.  Any suggestions?

Raymond Frost
University of Miami

---

From: postarch (Postgres Mailing Archive)
Date: Fri, 07 Feb 92 09:44:51 PST

> do instead [ append cat (tail = "swishing") append trace (rule_fired =

There currently isn't a way to put multiple queries in action clause of a
rule.

> chaining.  Any suggestions?

What you really want is the explain command.  Where instead of
running the query the system tells you what actions would be taken if the
query had been executed.  Unfortunately we don't have that either.

The only way I can think of is to put a rule_fired field in the cat relation
and define the rule as:

	define rule foo_bar is
	on append to dog where new.tail = "wagging"
	do instead append cat (tail = "swishing", rule_fired = "foo_bar")

There is probably something more clever that could be done, but I can't
come up with anything else off the top of my head.

Jeff Meredith
[email-masked]

---

From: postarch (Postgres Mailing Archive)
Date: Fri, 07 Feb 92 13:05:12 PST

I wrote:

> --------

It has been brought to my attention that this statement is wrong.
The correct syntax to do this is:

        define rule foo_bar is
        on append to dog
        where new.tail = "wagging"
        do instead [
                append cat (tail = "swishing"::char16)
                append trace (rule_fired = "foo_bar"::char16)
        ]

and sure enough it works as expected... The reason your original query didn't
work right was that you needed to use the keyword new before specifying the
tail attribute... sorry for the botch.

It's a good thing that the "Official Postgres Rules Person" is still
listening in....

Jeff Meredith