Subject: Conditions in rules

From: [email-masked] (Patricia Lynch Carbone)
Date: Wed, 1 Apr 92 10:54:59 -0800

I'm finally back to using POSTGRES again for my Navy application.
I have a question regarding conditions in rules.  Neither the POSTGRES
user manual nor any of the video scripts show the use of a rule with
a condition.  For example,
	ON append to emitter-relation
	when emitter-relation.type="fire-control" and
		emitter-relation.flag="hostile"
	do action...
Does POSTGRES allow this any more?  I thought it did when I was using
V3r0 last year, and I spoke to Greg Kemnitz about some of the problems
I was having.
	If there is a paper that I missed somewhere along the line
discussing how to do this, I'd really appreciate reading it.  I also
have 12 of Dr. Kerschberg's students at George Mason who are supposed
to do an assignment using conditions in rules, so they will appreciate
knowing if this has been implemented!
	Thanks a lot!

--Tricia Carbone
The Johns Hopkins University Applied Physics Laboratory
Laurel, MD

---

From: postarch (Postgres Mailing Archive)
Date: Wed, 01 Apr 92 19:07:38 PST

you write:
> Does POSTGRES allow this any more?

Yes, you're just using the wrong syntax:

	define rule wow is
	on append to emitter_relation
	where new.kind="fire-control" and
	      new.flag="hostile"
	do instead
	append emitter_relation (flag = "wow"::char16, kind = "jeez"::char16)

The differences are:

	the keyword "where" instead of "when"
	every - should be a _ 
	type is a reserved word

	to get the semantics that I *think* you want you need to use
        the reserved word "new" in your qualification...

casts were apparently needed in the target list of the action
(i got a WARN without them), but I'm not sure why...

Jeff Meredith
[email-masked]

P.S. I would love to hear more about your application.