Help me understand if this logic is correct

Kindly explain what is expected if Step 3 does not contain data. Assuming run should be stopped

Logic looks fine. But based on your steps - there is no end point if data is available even after couple of loops

  1. Create an integer variable i and assign the value as 0.
  2. Create a boolean variable - boolContinueRun and set value as True
  3. You can use a do while loop like below
  4. DO
    Increment i variable
    Run Query
    Get Interim Output
    Based on interim output - compare and get actual output
    If Output does not contain data OR i>4 (or the max loop expected)
    Set boolContinueRun =false

While (boolContinueRun=True)