Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA22199; Wed, 1 Apr 92 19:07:51 -0800
Message-Id: <9204020307.AA22199@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: Conditions in rules
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Wed, 01 Apr 92 10:54:59 PST."
             <9204011854.AA15412@postgres.Berkeley.EDU> 
Date: Wed, 01 Apr 92 19:07:38 PST

you write:
> 	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?

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
mer@postgres.berkeley.edu

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