Sir,
I have a trigger program on a file (File1) with INSERT / UPDATE / DELETE. The requirement is to execute the business logic on the same file (File1). So I'm opening File1 in trigger program in update/add mode.
I know that it is not recommended to use the same file in trigger program.
The question is, how can I get out of the trigger program, once I execute my logic on File1?
Thank you for the help in advance...
Mahesh
Software/Hardware used:
ASKED:
November 22, 2004 6:56 PM
UPDATED:
November 11, 2011 12:12 AM
Hi
You do not need to open the file for update.
If you use the original DB to create an external data structure and base it on a pointer
e.g.
D p_After s *
D MYds e ds ExtName(myDB)
D based(p_After)
You can then set the to the memory after image
Eval p_After = %addr(Parm1) + AftOffset
Parm1 is the standatd Parmeter 1 and the standard afrter offset (I can not remember the exact position)
If you then update the data structure and add the trigger on the *Before event with ALWREPCHG(*YES)
The updated image is written to disk.
Dave
The trigger program which is called based on the trigger criteria on the file should not update the same file. You will have an ugly loop. You should reconsider triggering the file and updating with the same program. Maybe have the trigger program write to a work file from which another program applies the updates to the original file.
Good Luck.
If your trigger pgm updates the file it is defined on, then you will cause the trigger to fire ad infinitum. Find some other way. The only acceptable reason to open FILE1 in the trigger is if you are firing it BEFORE the update/insert and modifying the new record image with ALWREPCHG(*YES).
Hello,
Setting on the LR indicator should end your program. It works with my trigger programs.
how trigger in as400….??
how trigger in as400….??
How what? Do you need to know how to create triggers? …how to add a trigger to a table?
This might be better if you create a new question. Include more detail to describe the problem you are having.
Tom