Problem solve Get help with specific problems with your technologies, process and projects.

Easily maintainable triggers

Here's a workaround for modifying a trigger program that you can't get an exclusive lock on the object.

Have you ever needed to modify a trigger program, but couldn't compile the program because you couldn't get an exclusive lock on the object because the database file it was attached to was in use?

Well, I have found an easy way around that problem. Use two programs. The first program is a driver, and it is the one used on the ADDPRTRG. All it has in it are the trigger parameters (in data structures), and a call to a workhorse program. The second program is the one that actually does the work of the trigger, and it accepts the trigger parameters as *ENTRY Parameters, and then does the work.

This way, if you ever need to disable or change the function of a trigger, you never have to contend with the database locks, you just modify the workhorse, and re-compile it. The driver never gets touched, unless there is a change to the database file, in which case you need an exclusive lock anyway.


The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.