LOGGING changes in a Table

SKaushal

New Member
Hello Everybody,

I need your help!!!

I have to maintain a log of all the changes made to a Record in a Table, whether the record is deleted or modified or created. I have to store the field changed and details who changed it an when. Also I have to store the new changes in the record simultaneously.

I'm using progress 8.2 on unix its CHI.

Thanks in advance for your suggestions.

SK
 

Casper

ProgressTalk.com Moderator
Staff member
Just a quick answer: Make the log in the delete and write triggers of this table.

Casper.
 

Casper

ProgressTalk.com Moderator
Staff member
Hi there,

Triggers are normal Progress procedures. Triggers are there to maintain database integrity. For most tables in the application you have, triggers probably are defined. You define write en delete triggers in the data dictionary.

There are some extra statements you can you can use in these kinds of triggers.

Like this:

A typical start for a write trigger is:

TRIGGER PROCEDURE FOR WRITE OF table-name OLD BUFFER o-tablename.

This means you have created a buffer o-tablename which contains the value before the changes. This way you can access both old and updated values of fields in that table.

Another important keyword is NEW. You use it like this: IF NEW customer then do: .....code ...... end.

This means: if the customer record has just been created.
With this you can distinguish between updated and newly created records.
To write the log you just have to output this information to a file or to another table.
But essential is that the trigger procedure must have been defined in the data dictionary.

HTH,

Casper.
 

jongpau

Member
Don't forget that you may want to modify any procedures you may have that do buLk loads into the database... in that case you probably don't want the triggers to fire (causing a stack of information in your log table(s) and a heap of overload). For those situations you can use "DISABLE TRIGGERS FOR LOAD OF <table-name>." which you can add to the load procedure(s).
 
Top