Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating A Trigger File

Status
Not open for further replies.

pebbleflux

Programmer
Apr 13, 2003
2
SG


How do i update a trigger file?

thanks.
 
You need to use ADDPFMTRG to specify the program to call when a record is added, deleted or changed. You can specify the trigger to fire before or after each event but you can only specify one at a time so you have to do the ADDPFMTRG for each one. The trigger program is passed data which has a header section to tell you which event has occurred and whether it is before or after the event. Then it has a string which gives you an image of the data which has changed. The best bet here is to define an externally defined data structure using the trigger file name then just use EVAL to set this equal to the string which has been passed.

ps. it ain't a good idea to change the trigger file in the trigger program because this kicks up a Recursive Call error message.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 

yeah, i know doing an update in the trigger program will cause the pgm to go into a loop.

now how do i update? i really need to, is there any other way to do an update?
 
I can't think of any. Whichever way you update the data it is going to fire the trigger. Even if you have a workfile with the same layout and write to it, when you write or update these records back to the main file it will fire the trigger. If you didn't need to track adds or deletes and you didn't do ADDPFTRG for the *ADD/*DELETE events you could delete the record, change the fields then write a new record. Then it wouldn't fire the trigger program because you weren't doing an update but that may not be practical/possible.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top