Kbase P6138: How to track table changes and monitor the programs changing
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/2/2003 |
|
Status: Unverified
GOAL:
How to track table changes and identify the programs involved in these changes?
FIX:
The following is a sample monitoring WRITE trigger for the Item table. This trigger monitors the quantity on hand. When this field changes, a new monitoring record is created and some tracking information are recorded.
The information captured includes the current program name and the calling programs sequence 7 levels deep.
TRIGGER PROCEDURE FOR Write OF Item OLD BUFFER oldItem.
IF ITEM.On-Hand <> OldItem.On-Hand THEN DO:
/* Create a new record in the monitoring table */
CREATE OnHandMonitor.
ASSIGN
OnHandMonitor.DateChanged = TODAY
OnHandMonitor.TimeChanged = STRING(TIME,"HH:MM:SS")
OnHandMonitor.UserChanged = USERID
OnHandMonitor.Item-Num = Item.Item-num
OnHandMonitor.Item-Name = Item.Item-Name
OnHandMonitor.Old-On-Hand = OldItem.On-Hand
OnHandMonitor.New-On-Hand = Item.On-Hand
OnHandMonitor.Proc1 = PROGRAM-NAME(1) /* current program name */
OnHandMonitor.Proc1 = PROGRAM-NAME(2) /* calling program name */
OnHandMonitor.Proc1 = PROGRAM-NAME(3)
OnHandMonitor.Proc1 = PROGRAM-NAME(4)
OnHandMonitor.Proc1 = PROGRAM-NAME(5)
OnHandMonitor.Proc1 = PROGRAM-NAME(6)
OnHandMonitor.Proc1 = PROGRAM-NAME(7).
END.