Using procedures to maintain derived data
Posted in 1995
Informix (unlike some unnamed databased which handily support calculated fields) seems to keep their version of SQL well behind the current standards. This means that I have to write and maintain a stored procedure to keep my calculated fields up to date. What a pain. Are you listening Informix? Anyway, gripe mode off. Anyway, my limited exposure to triggers and SPL seems to indicate that in order to keep a header record updated with respect to its detail, an update trigger on the appropriate detail fields is in order. Ideally, one would specify an after() clause to update the header once after all the detail records have been updated. Since multiple records are going to be modified, and they are in no way required to be from the same master-detail relationship, I run into the dilemma of specifying which headers need to be recalculated. The only way I can see to do this is to update the header for each row. This seems to be an untenable solution for the size of the dataset I'm dealing with, although I haven't tested it yet. My other option is to accumulate a list of all headers which require updating while processing each detail update, but SPL is conveniently devoid of array capabilities. Am I missing something here? Neither the 5.02 nor the 7.1 online engine seems to provide any functionality to handle this kind of situation easily. True, good normal form theory decries derived data, but this is a real life situation, and such fields are necessary to performance and ease of use. Can anyone help? Many thanks in advance. -- Mike Lemon mdl@interpath.com