Looping While In a Loop - VisualCron - Forum

Community forum

Neil Frost
2017-05-02T13:31:28Z
I have a loop that does the following:
Get Information from SQL database - Return is a single column with a row of Customer ID's
Loop Through each ID and retrieve information from Web Service - Return is a list of additional ID's from the web service
At that point I want to loop through those additional ID's to get information from another web service, but remain within the first loop.

To make is clearer...

Result from SQL looks like:

AABBCCDD112233
ABCDEFGH445566
RREEWWSS998877
WWSSDDFF44335512


I then want to go to
http://awebservice.com?id= AABBCCDD112233

Result would be:

John Smith
Dave Johns
Terry Graves
Brian Munks


I would then want to loop through those names and run

http://bwebservice.com?Name=" John Smith"
Result would be :
12 Anywhere
Somewhere
Essex
SS43 5GT
Then write that to a SQL table

Then
http://bwebservice.com?Name=" Terry Graves"
Result would be :
221b Baker Street
London
NW1 6XE
Then write that to a SQL table

Then
http://bwebservice.com?Name=" [bDave Johns[/b]"
Result would be :
654 Somewhere Else
Nowehere
Nottingham
NT12 3PQ

Then write that to a SQL table

Etc... through all of the names in the result set.

THEN it would run the next iteration through the first loop:

http://awebservice.com?id= ABCDEFGH445566
Result would be:

Rudolf Bruner
Edmond Behan
Seth Lowrie
Porfirio Fukuda
Moses Zurcher
Ahmed Nauman


and it would go through the results above and run
http://bwebservice.com?Name="  " .....
for each

And so on until the first set of results has been looped through.

How would I handle this?
Thanks
Neil
al355
2017-05-02T18:01:56Z
The only way to do this is to have one job call another job, each of which has a loop
ErikC
2017-05-05T08:36:39Z
Hi Neil,

This is indeed the way to go. Use the Job variable in the task control task to set a variable with the names retrieved from the webservice.
This 2nd job should use this job variable as the looping itteration.

You also can make this in one job, but the 1st loop must be a discarded and you must make it with conditional jumps and with extra variables, but that's a bit harder to setup.
I would go for al355 solution.

Regards
Erik
Uses Visualcron since 2006.
Scroll to Top