Re: Question on triggers
Posted in 1994
voorst@dordt.edu (Dale Van Voorst) writes: >Two questions regarding triggers: >1) Do I have to special order the book on triggers? I'm quite sure that >it didn't come with my engine or tools manuals. I thought I came with version 5.01 and above engine product. Call and ask for part number 000-7230. >2) Since I currently have no book, can someone tell me if the following >idea is applicable to the use of triggers. >I want to keep track of the date of the last change to each row in a >table. I'd like to avoid programming everything in 4gl just to make >sure that the date always gets updated. It seems that triggers might >be just the ticket. If I could automatically trigger an update of the >date field whenever a row is updated, my life would be much easier. >Is this a feasible use for a trigger? If not, any suggestions would >be appreciated. You can't update the triggering row with the trigger, so you can't update a column in the same row, I guess because of the infinite loop you would be conceivably be creating (since the update would trigger the action again, etc.). You could, however, have a table history table and have a trigger that calls a stored procedure that inserts the table name, PK, and date of last change into it. You could even use the USER syntax to record WHO made the change. ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed are Senior Consultant -------------------- soley my own, & do not Informix Software Inc Voice: 303-850-0210 necessarily reflect Denver Colorado USA Fax: 303-779-4025 those of my employer.