Subject Re: [IB-Architect] Trigger Templates
Author Joseph Alba
>A better solution to your problem is table inheritance, not trigger

But if triggers have a hidden parameter SELF pointing to the calling Table,
Is it not possible for a trigger to be 'shared' by different tables, just
like in Delphi where event handlers -- so long as they have the same
parameters, can shared by different components / forms.

Parameters of triggers can be considered as the set of the (table) fields
(New. / Old.) that the trigger contains.
I mean, as long as tables contain these fields, it can share the template
trigger. Referential Integrity constraints can be extended to these fields.

It would work something like this:
> 1. Define a table call BASE containing creation timestamp,
> creating user, last modification timestamp, and last
> modifying user.
> 2. Define insert and update triggers for BASE to populate
> the appropriate fields.
> 3. Define you favorite 400 tables with "extends BASE". Each
> inherits the fields and triggers of BASE.

This is like the mix-in example I gave

create table CLIENT [inherit] from Person, TimeStamp_Mixin
- with a base table TimeStamp_Mixin has static triggers attached to
implement timestamps

which would really be elegant.

But the former example (of template triggers) is more like a FRIEND or
Interface. (Many ways to skin...)

[Or, you can say, its a choice between Inheritance or Delegation]

>This could be done in the engine or an external DDL utility. It
>is more powerful to use, much easier to implement, without a
>performance impact, and much more elegant. You will also find
>that it solves a host of other problems.
Yes. I think with BLR, it is indeed possible to develop source language
extensions, pump it into a preprocessor, have the blr target code assigned
to a resource string, ... and a host of other possibilities. BLR is a most
underutilized asset of IB, I think.

>I may have the code in the attic. I'll look.
>Jim Starkey

Something which I think you'll be doing more often...
Like they say, Genius is being ahead of your time.
(I remember the song, Starry Starry Night)

Joseph Alba