Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA03919; Mon, 18 Nov 91 07:03:26 -0800
Date: Mon, 18 Nov 91 07:03:26 -0800
Message-Id: <9111181503.AA03919@postgres.Berkeley.EDU>
From: seligman@starbase.MITRE.ORG (Len Seligman)
Subject: rule questions
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Cc: kersch@gmuvax2.gmu.edu, len@starbase.mitre.org

Dear PG Developers,

1. Is it true that one can only bind variables from one class on the left-
hand side of a rule (i.e., the where clause)?  Please give me guidance on
how I ought to code the following example.

Schema:
        emp(id, name, dept, salary)
        dept(name, site)
Problem:
I want to be notified about any employees at the Washington site who make
over $40,000.  This requires four rules, one for each of the following
conditions:  a) when a new employee is added, b) when an employee's dept
changes, c) when an employee's salary changes from less than to greater
than or equal to $40K, and d) when the site of a dept changes to "Washington".
The first 3 rules are easy to code, but I'm having problems with the last
one...

define rule change_site is
on replace to dept.site
where new.site = "Washington" and
        new.name = emp.dept and
        emp.salary >= 40000
do alert_application(arg_list)

The problem is how do I get the employee's name and salary in the argument
list of this function alert_application?  Is there any way to bind them
to tuple variables, or can that only be done on one class per rule?  If that's
the case, any suggestions on a workaround?

2. Is there any way to check an EXISTS condition in a (forward-chaining)
alerter rule?  In other words, I only want the rule to fire the first time
the condition is detected, not every time.  If there is no such
facility, do you have any ideas for how I might get that functionality?

Thanks,

Len Seligman
The MITRE Corporation                   (703) 883-5975
7525 Colshire Drive W418                FAX: (703) 883-6435
McLean, VA 22102                        email: seligman@mitre.org

