Subject: append problem

From: [email-masked] (Raymond D. Frost)
Date: Thu, 30 Jul 92 16:11:26 -0700

The following series of commands hang-up the system.
Any help will be appreciated.

create auto
        (serial = char16,
        style = char16,
        color = char16,
        price = int4,
        category = char16)
\g
define rule CatEconomy is
on append to auto
   where new.price >= 10000
     and new.price <  20000
   do instead append auto
      (serial = new.serial,
       style  = new.style,
       color  = new.color,
       price  = new.price,
     category = "Economy")
\g
append auto
        (serial="2222",
         style="sedan",
         color="red",
         price=15000)
\g

Sylvia Shelley
University of Miami

---

From: <[email-masked]>
Date: Thu, 30 Jul 92 16:41:03 PDT

>          price=15000)

when you append your auto tuple, you fire the CatEconomy rule.  CatEconomy
appends a tuple to auto that satisfies the requirements for firing the
CatEconomy rule, so it fires on its own output.  this continues forever.

you should reformulate your rule so that it changes some condition in
the tuple, and keeps itself from firing forever.

					mike olson
					project sequoia 2000
					uc berkeley
					[email-masked]

---

From: Spyros Potamianos <[email-masked]>
Date: Thu, 30 Jul 92 16:58:18 PDT

> define rule CatEconomy is

The system enters an infinite rule loop!!!!
What happens is that the append command causes rule 'CatEconomy' to fire,
and do another append, which in turn causes the rule to fire again, which
causes another append, which.... ad infinitum....

If I guess corrctly what you want to do is to let the system automatically
fill in the "category" attribute. To achieve this effect you can
define the rule:

 define rule CatEconomy is
 on append to auto
    where new.price >= 10000
      and new.price <  20000
    do instead replace new(category = "Economy"::char16)

This rule will be activated whenever a new tuple that satisfies its
qualification is appended. As a result, it will fill in the "category"
attribute with the appropriate value, and proceed with the tuple
insertion.
Note that you have to explicitly cast "Economy" to "char16"!
The parser is not clever enough to deduce the right type for "category"...

Spyros Potamianos
[email-masked]