Subject: Can I do this

From: Kent Archie <[email-masked]>
Date: Thu, 1 Oct 92 0:55:12 CDT

I am trying to build a database for a
software maintenance environment and hope to use Postgres
to do it. Looking at the documentation and trying some things
didn't answer all my questions so I thought I would ask here.

What I need to do is this:
There are a number of objects in the database that have dependencies
on each other and can get out of date with respect to each other.
When a query is made on table A, I want to check whether it
is current with respect to table B and if not, execute code
to bring A up to date (values in A are derived from values in B) 
and then execute the original query.

I looked at rules as a way to control this.
But the docs say that rules can't have multiple POSTQUEL
statements in the event of a retrieve and it's not clear
that I can get it to execute C code at this point to do 
the update.  It is even less clear how I get it to restart 
the original query.

This may be beyond the scope of this database, but I would
appreciate any suggestions.
**kent
Kent Archie
[email-masked]

---

From: Lance Gatrell (303) 977-2052 <[email-masked]>
Date: Fri, 2 Oct 92 09:22:54 -0700

> the update.

C code can do this.  Unfortunately, it has been our experience that
you can't pass a tuple to the function when the function is executed 
as the result of a rule (you can pass a tuple when calling the function
directly, just not when a rule calls the function).  So we pass the oid
of the tuple to the C function, and then retrieve the tuple through a portal.
Inside our C function we do some computations and then append several
records to another table.

I'm pretty confidant that you can do what you are talking about with
a C function, since you can access multiple tables (appends, retrieves,
etc.) through the C function.

Lance B. Gatrell
[email-masked]

---

From: Lance Gatrell (303) 977-2052 <[email-masked]>
Date: Fri, 2 Oct 92 09:26:19 -0700

Lance B. Gatrell
[email-masked]