× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Trigger program being called recursively
  • From: Peter_Vidal@xxxxxxxx
  • Date: Mon, 7 May 2001 11:43:43 -0400


I found this: http://archive.midrange.com/rpg400-l/


Re: Unable to Execute Trigger..?

     Subject: Re: Unable to Execute Trigger..?
     From: dhandy@xxxxxxxxxxx (Douglas Handy)
     Date: Fri, 17 Mar 2000 19:28:21 -0500

Scott/AB,

>If you want to make changes inside a trigger, make the changes to the
>"AFTER" record buffer.  This will cause it to be written to the file by
>the operating system.

Or better yet, starting with V3R2 and V3R7, you could use a *BEFORE
trigger and specify ALWREPCHG(*YES) to enable "allow repeating
changes".  This is precisely to handle the situation described, where
the trigger wishes to modify the record being added/inserted by the
underlying application.

But instead of having the trigger program perform any I/O (which
causes the recursive loop you described), with ALWREPCHG(*YES) the
trigger just modifies the trigger buffer.  The modified buffer is then
written to disk instead of the image from the application program.  No
additional disk I/O, and no recursive calls generated.

The default is ALWREPCHG(*NO) to you don't accidentally modify a
record, and to remain backward compatible with triggers prior to V3R2
and V3R7.  Also note it must be a *BEFORE trigger, not *AFTER.



                                                                                
                
                    jfinney@omnia.co.                                           
                
                    za                       To:     RPG400-L@midrange.com      
                
                    Sent by:                 cc:                                
                
                    owner-rpg400-l@mi        Subject:     Trigger program being 
called          
                    drange.com               recursively                        
                
                                                                                
                
                                                                                
                
                    05/07/01 09:51 AM                                           
                
                    Please respond to                                           
                
                    RPG400-L                                                    
                
                                                                                
                
                                                                                
                





Hi all,

I've a problem with a trigger program. The trigger is *AFTER/*UPDATE and,
when fired, it needs to update records in the same file. How do I make sure
it does not call itself recursively (as I am currently receiving this error
message).

Parms on ADDPFTRG CL cmd

Physical file
  . . . . . . . . . > EWR
  Library  . . . . . . . . . . .     *LIBL
Trigger time . . . . . . . . . . > *AFTER
Trigger event  . . . . . . . . . > *UPDATE
Program  . . . . . . . . . . . . > T_EWRR01
  Library  . . . . . . . . . . .     *LIBL
Replace trigger  . . . . . . . . > *YES
Allow Repeated Change  . . . . . > *YES
Threadsafe . . . . . . . . . . .   *UNKNOW
Multithreaded job action . . . .   *SYSVAL
Trigger update condition . . . . > *CHANGE

Regards
John.




+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.