for each nested each

GirlNet

Member
Please bare with me as I'm really new to Progress and I'm trying to make headway.

What's wrong with this statement? It just hangs . . . Am I trying to complicate things again? :rolleyes:

for each ck_mstr no-lock,
each ap_mstr no-lock where ap_mstr.ap_ref = ck_mstr.ck_ref
and ap_effdate >=st-dt and ap_effdate <=end-dt,
each ad_mstr no-lock where ad_mstr.ad_name = ap_mstr.ap_vend:
if available ad_mstr then name = ad_name.
if available ck_mstr then chknbr = ck_nbr.
end.
 

TomBascom

Curmudgeon
Please bare with me as I'm really new to Progress and I'm trying to make headway.

What's wrong with this statement? It just hangs . . . Am I trying to complicate things again? :rolleyes:

How many records are in these tables?

How long do you let it hang for?

Do monitoring tools (PROMON, ProTop and so forth) show that there is lots of activity going on?

You could put a message inside the body of the loop and get a feel for how quickly records are being processed.

Code:
for each ck_mstr no-lock,
        each ap_mstr no-lock where ap_mstr.ap_ref = ck_mstr.ck_ref
            and ap_effdate >=st-dt and ap_effdate <=end-dt,
        each ad_mstr no-lock where ad_mstr.ad_name = ap_mstr.ap_vend:
            if available ad_mstr then name = ad_name.
            if available ck_mstr then chknbr = ck_nbr.

    message ck_mstr.ck_ref ap_mstr.ap_vend ad_mstr.something.

end.
 

GirlNet

Member
Thank you so much TomBascom for taking the time to answer. I found the issue (I think). It should be:

for each ck_mstr no-lock,
each ap_mstr no-lock where ap_ref = ck_ref
and ap_type = "CK" <-------------------here
and
ap_effdate >= st-dt and ap_effdate <=end-dt,
each ad_mstr where ad_addr = ap_vend
break by ck_nbr:
if available ad_mstr then name = ad_name.
if available ck_mstr then chknbr = ck_nbr.
end.

It seems adding the filter helped - but I still don't have a clue why it hung for so long. I let it run for a few minutes.

But . . . I was going to ask what kind of tools for available for monitoring these types of issues - which you already answered. I used promon before but not protop. I'll have to research it.

Thanks again.

Thanks much!
 

enoon

Member
Thank you so much TomBascom for taking the time to answer. I found the issue (I think). It should be:

for each ck_mstr no-lock,
each ap_mstr no-lock where ap_ref = ck_ref
and ap_type = "CK" <-------------------here
and
ap_effdate >= st-dt and ap_effdate <=end-dt,
each ad_mstr where ad_addr = ap_vend
break by ck_nbr:
if available ad_mstr then name = ad_name.
if available ck_mstr then chknbr = ck_nbr.
end.

It seems adding the filter helped - but I still don't have a clue why it hung for so long. I let it run for a few minutes.

But . . . I was going to ask what kind of tools for available for monitoring these types of issues - which you already answered. I used promon before but not protop. I'll have to research it.

Thanks again.

Thanks much!

Just a little note for the future.
The IF AVAILABLE test are useless since every time you do a:
Code:
FOR EACH <record>: 
(here the <record> is always available) 
END. 
(here the <record> is no longer available)
 

tamhas

ProgressTalk.com Sponsor
Unless you have some other code, this code doesn't really do anything except assign some values to some variables. No display, no message, no log, no change to the record ... at least it isn't apparent from this piece whether any of those values are variables or field names. You should *always* qualify a field name with the table name.
 

GirlNet

Member
Thank you for the advice. You're right . . . I didn't post the entire code - there was more. I just wanted someone to validate the code I had written was correct.

Plus, since I'm new to Progress I'm not sure about how to debug. I'm used to being able to step through code to find variable values and result sets.

Thank you again for taking the time to respond.
 

Cringer

ProgressTalk.com Moderator
Staff member
The simplest way to debug something like the above is to use the MESSAGE keyword.

MESSAGE lvVariable VIEW-AS ALERT-BOX.

Something like that. You might want to develop this further to include yes/no buttons that updates a logical and can drop you out of the program to save having to sit through days' worth of messages.
 

Casper

ProgressTalk.com Moderator
Staff member
IMO the simplest way to debug is use the debugger.
If you quickly want to debug then put the following two lines of code in the program:
Code:
debugger:initiate().
debugger:set-break().
then from here on the debugger takes control.

Casper.
 

Cringer

ProgressTalk.com Moderator
Staff member
Yeah I suppose... I don't use the debugger because it breaks things in the apps I work on currently.
 
Top