Knowledge : 👀
While Loop? : Loop over actions or invoke connections as long as a specific condition is met. You define the condition for the while loop in the Expression Builder.
Lets understand the While Loop by the help of one Hands-on Practice. In Part 1 we will compare numbers and in Part 2 we will compare String in while loop expression builder.
PART 1 :
Compare Numbers in While Loop | Oracle Integration Cloud :
Use case : lets develop one Schedule Integration using While Loop which will keep executing till the time a specific condition is not fulfilled (for ex :- condition is While Loop will keep running till the time Variable_B value > Variable_A value). Once the condition failed, while loop execution will get end.
STEP 1: Create one Schedule Integration.
STEP 2: Add Assign activity, give some meaningful name & then declare Two Variables (ex : - var_A and var_B ). Initialize the variables by assign values 1 and 10 respectively. (as shown in below image)
- Compare the variables as shown in below image
Expression : number($var_B) > number($var_A)
STEP 4 : Now add one Assign activity inside the While Loop to keep increasing the Variable_ A value by 1 after each loop completion.
- Build the expression to keep increasing the Value of Variable A (var_A) after each iteration. (take reference from below image )
Expression : number($var_A) + 1.0
STEP 6 : Save the Integration & Activate the Integration.
- Click on the Instance Id that got generated after submission to track the Flow.
You can see it clearly While Loop executed 9 times and came out the loop when condition failed (i.e when var_A value became equal to var_B value.) This way we have successfully completed one While Loop POC. I hope this helped you to understand While Loop use in Oracle Integration Cloud.
PART 2 :
Compare String in While Loop | Oracle Integration Cloud :
Note : To compare String using While Loop you can use contains function (as shown in below image ). You can't simply compare two string in while loop expression builder. It will Error out.
Thank You !
Nice explanation, Appreciate. Is it possible in For Loop ?
ReplyDeleteThanks. No its not possible in FOR loop. But one suggestion I can give : You can use WHILE Loop Inside FOR Loop to fulfil your requirement.
Deletehow to reverse the string using while
ReplyDeleteyou can try this : Inside WHILE loop, use ASSIGN activity, inside ASSIGN activity by using some STRING FUNCTION you can reverse the string
DeleteHow to avoid "While loop exceeded Upper limit.
ReplyDeleteIt executed 5,000 times." issue