forcase loop with where
Posted: December 28th, 2019, 3:50 pm
The help says it executes 1 or more times, even if the where condition is not satisfied.
Don't you think this is a little bit tricky? For example
forcase BRUMA_75_DOMICS_DICT where DD00_SETOR = setor do
.....
endfor;
Even if there are no cases in the file where DD00_SETOR = setor, the loop is executed once.
So, in order to catch only the cases where DD00_SETOR = setor, process and count them, you have to duplicate the where condition inside the for loop with a
if DD00_SETOR <>setor then next; endif;
It seems to me that the syntax to force at least one execution should be something like
forcase
.....
where ...
endfor;
Like the do ... while
Don't you think this is a little bit tricky? For example
forcase BRUMA_75_DOMICS_DICT where DD00_SETOR = setor do
.....
endfor;
Even if there are no cases in the file where DD00_SETOR = setor, the loop is executed once.
So, in order to catch only the cases where DD00_SETOR = setor, process and count them, you have to duplicate the where condition inside the for loop with a
if DD00_SETOR <>setor then next; endif;
It seems to me that the syntax to force at least one execution should be something like
forcase
.....
where ...
endfor;
Like the do ... while