"Fred Finken" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Here's an idea that I haven't actually tried, but it sure seems like it
> should work:
>
> You have two related files - say ORDERS and CUSTOMERS. You want any change
> to CUSTOMERS name to be reflected in the ORDERS file's CUSTOMER.NAME
index.
>
> First index the customer number in the ORDERS file. Add date & time
> fields to ORDERS. Then put a trigger on CUSTOMERS. The trigger routine
> uses the customer number index on ORDERS to determine which orders belong
> to the customer being updated. Using this info, the trigger stamps those
> ORDERS items with the date & time of the customer update. Now because the
> appropriate ORDERS items are being updated, their indices will all be
> re-evaluated and if the customer name has changed, the CUSTOMER.NAME
> index will be updated.

Doesn't work Fred.

> because the appropriate ORDERS items are being updated, their indices will
> all be re-evaluated

this is true, but...

> and if the customer name has changed

...this is where a problem lies.  The index software evaluates CUSTOMER.NAME
before and after the ORDERS file is updated - any change it detects will be
between these two points, not from where the index was last updated and now.
Both checks will give the same name so the index won't be updated.  (As it
happens the old name, because using a trigger on CUSTOMERS to run this
ORDERS update means that the new name has not yet been written).

What would be great is if Unidata provided a facility to update an index in
a file programatically.  Something like:

err=CHANGEINDEXITEM(file.var, index.name, key.val, original.index.value,
new.index.value)

and I suppose for completeness:

err=DELETEINDEXITEM(file.var, index.name, key.val, original.index.value)
err=ADDINDEXITEM(file.var, index.name, key.val, new.index.value)

They could put a '!' warning in the manual saying use at your own risk.

Your CUSTOMERS trigger would then call this for each item in the ORDERS file
with that customer...

CHANGEINDEXITEM(fpORDERS,"CUSTOMER.NAME",ORDERNO,OLD.NAME,NEW.NAME)

Simon
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to