Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA04290; Wed, 9 Jun 93 22:33:09 -0700
Date: Wed, 9 Jun 93 22:33:09 -0700
Message-Id: <9306100533.AA04290@postgres.Berkeley.EDU>
From: joseash@bush.cs.tamu.edu (Alfredo Sanchez)
Subject: Is notification possible using rules and fns?
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu


Hello,

I was trying to use rules to implement some sort of notification
upon changes to some instances but I've found a few probs.
It seems that I need to review the writings on the semantics of
instance-level and rewrite rules, but before digging into the papers,
I'd like to check whether someone else has done something similar.

In essence, I have a class called "Attributes" with fields
"name" and "value", both of them of type "text".

I define a function like:

define function notify_user
(language = "c", returntype = bool, trusted = false)
as "/home/accts/joseash//notify.o"\g

The C function is a trial one:

#include <stdio.h>
int notify_user()
{
 printf("Document status has been changed");
}

Then I define a rule:

define rewrite rule notify_user
is on replace to Attributes.value where Attributes.name = "Doc_Status"
do retrieve (x=notify_user())\g

When a "replace" is done, it seems that the where-clause is 
ignored, I suppose because this is a rewrite rule. The problem is
I couldn't define it as instance-level, as postgres would complain
requiring that

WARN:Jun  9 23:38:36:`on retrieve ... do retrieve' tuple rules must 
have an `instead' (And I do want to execute the function in addition to
replacing)

So the rule is always fired. 
What happens to the function's output?
Do I have other alternatives to do this?
Will listen/notify in upcoming releases help?

Thanks a lot for your help.

Best regards,

J Alfredo Sanchez H
-------------------
Hypermedia Research Lab
Texas A&M University
