Announcement
Collapse
No announcement yet.
Endless loop with no commit
Collapse
X
-
Lol, I think I have the same OCD problem, I've never liked infinite loops and code in the same way as you. I also think it's more human readable.
-
Hi Birgitta, I can't believe I forgot about ON-EXIT. That would work perfectly for this.
-
Originally posted by Barbara Morris View PostIn the future, if you have an endless loop with some code you need to run after the loop, use the %SHTDN built-in function within the loop to see if the job is trying to end. If %SHTDN returns true, then exit the loop. (And make sure you end the job *CNTRLD to give it time to do the code after the loop.)
Code:dow 1 = 1; ... some code ... [COLOR=#FF0000] if %SHTDN(); leave; endif;[/COLOR] enddo;
Code:exitloop = %SHTDN(); dou exitloop; ... some code ... exitloop = %SHTDN(); enddo;
Leave a comment:
-
Barbara,
wouldn't ON-EXIT work, too?
Code:Dow 1=1; ... whatever you do EndDo; On-Exit; Commit; ... or whatever you want to do
- Likes 1
Leave a comment:
-
In the future, if you have an endless loop with some code you need to run after the loop, use the %SHTDN built-in function within the loop to see if the job is trying to end. If %SHTDN returns true, then exit the loop. (And make sure you end the job *CNTRLD to give it time to do the code after the loop.)
Code:dow 1 = 1; ... some code ... [COLOR=#FF0000] if %SHTDN(); leave; endif;[/COLOR] enddo;
- Likes 1
Leave a comment:
-
Thanks for the replies, I had to end the job and restart. The do while condition was 1=1 and so I couldn't force the change in debug.
Leave a comment:
-
put the job in debug & force the condition to exit the loop is the only way i can think of
Leave a comment:
-
Just to confirm - you want to know if there is a way to manually end an existing running job that has activation group *NEW, so that it will commit all outstanding updates?
Leave a comment:
-
Endless loop with no commit
I have created a situation. I have an RPGLE program that is in a endless do-while loop running embedded sql statements to update data. It is done its work, but due to a logic problem it never reaches the exit point of the loop. It's in a *new activation group, and so if I end the job it never commits and I lose all of the work it has done. I would much rather find a way to end the program and commit the changes.
Any ideas?Tags: None
Leave a comment: