Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Should I Use a Trigger?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Should I Use a Trigger?

    Based on the situation you are describing, my thought would be that you would be better off to use a service program. Just call a function to determine the "current" status of the Y/N flags in the item file. Then return the same values you were thinking of using in the control file. There are two benefits to this. First, you will not have to be concerned with multiple trigger programs which can be difficult to modify/maintain. Second, you will always know what the state of the flags are at the time that you are depending on them. This always makes me feel more confident in with the code. All IMHO of course. ;-) Jeff Olen Olen Business Consulting, Inc. email: jmo@olen-inc.com phone: 760.703.5149 web: www.olen-inc.com

  • #2
    Should I Use a Trigger?

    I'm updating two files by adding a 1 byte field. The first file is a list of control id's and the second is a list of items for each of the control id's in the first file. The new field in the item file is a Y/N value to set if it is part of a control event. The control file's flag may be set to F=full, P=partial, or N=none. Full is if the event flags for all items associated with the control id are set to "Y". Partial is when some are "Y", and none is if none are set to "Y". I need to keep the flags in sync using these rules. I was thinking of using a trigger program on the item file that would change the flag in the control id file based on the previous rules. But I also need to check for direct changes to the flag in the control id file. If I use a trigger on the control id file, it would seem that I would be causing a recursive call as both the item and control id files would update the control id file, thus causing the firing of the trigger again. I think I'm making this more complicated than it has to be, but I'm having trouble figuring out how this should work. My next thought was to simply drop the flag on the control file and write a service program procedure to determine the status of each control id. Any suggestions? Thanks.

    Comment


    • #3
      Should I Use a Trigger?

      I would create 2 trigger programs. In each trigger, I would chain to the other file to compare the value of that field you want to keep in sync. With that situation, if you update control ID in file A, the trigger fires, chains to file B and compares the Control ID field. If they don't match, update File B and quit. This causes the trigger File B to fire, chains to File A and compares values. They match and the trigger ends. Make sure that you set the trigger to TRGTIME(*AFTER) otherwise you are back in that vicious loop!

      Comment

      Working...
      X