Q: I have a question regarding an insert/update *BEFORE trigger program written in ILE/C. If I modify the value of a field in the current record in a trigger program, will the modification be written to the database? From what I've read in the manuals, the trigger program can change the value but cannot issue an update.
- Tim Brown
A: You're correct. The OS/400 DB2/400 Database Programming V3R1 manual (SC41-3701, CD-ROM QBKAUC00) says this:
A trigger program can call other programs or can be nested (that is, a statement in a trigger program causes the calling of another trigger program). In addition, a trigger program may be called recursively by itself. The maximum trigger nested level for insert and update is 200. The trigger program must not cause the following situations. These situations result in an error if programs run under commitment control.
o Update the same record of the same file that has already been changed by the change operation or by an operation in the trigger program.
o Produce conflicting operations on the same record within one change operation. For example, a record is inserted by the change operation and then deleted by the trigger program.
Note: If the change operation is not running under commitment control, the change operation is always protected. However, updating the same record within the trigger program will not be monitored.
The update to the record cannot be done by the trigger program. It can update or write to other files (for example, audit logs) but not the record the program is being triggered by.
- Peter Rowley
LATEST COMMENTS
MC Press Online