Skip rest of loop body if table is empty


I hope this question has not already been answered elsewhere, but I could not find a corresponding topic. I hope this part of the forum is correct...


After some trial and error I have got a two nested loops in my workflow that seem to work well .... unless a table which provides the data for the inner loop body as well as the table for its "TableRow To Variable Loop Start" node is empty.

I have desperately searched the Flow Control Node section, but could not figure out how to skip in this case the inner loop body execution, and the iteration of the inner and outer loop and start over with the next iteration of the outer loop.

Any help appreciated, I really need to get on!


Thanks a lot !


kind regards


Will the "Empty Table Replacer" node work by placing it just before the "Table Row to Loop Start" of the inner loop.

Alternatively, to avoid failing due to an empty table, you could have a "Table Creator" node just prior to the "Table Row to Loop Start" with a dummy row in there. Just join  this dummy row to the main data with a "joiner" node. This way there is a guarantee of at least one row.


Dear Simon,

thanks a lot for your suggestions!


I already tried the first idea, but this basically stops all loops. So I will try the second option and let you know.





I encountered exactly this same problem just now.  I have 2 possible solutions, both of which can work, and which to use probably depends largely on what the inner loop does.

In both cases, prefix the inner loop with an 'Add Empty Rows' node, where you can specify that the table must have at least one row.  You need to ensure that the node puts something into each column type, for either solution.

Solution 1:

Put something into the empty table (such that all column types contain a value, otherwise the tablerow to variable loop start will fail with missing values), such that the inner loop will still run, and then suffix the inner loop with a row filter to remove this 'blank' iteration

Solution 2 (if solution 1 does not work in your situation):

Put something into the empty table such that all column types contain a value.  Make the String values something obvious like 'NoData'.  Take the output into a 'TableRow to variable' node, and the output of this to a Java Edit Variable node configured to generate a new variable called 'port', something like (where 'Col0' is the name of a string column in your table):

return ($${Col0}$$.equals("NoData"))?"bottom":"top";

Now, put the output of your 'Add Empty Rows' node into an If Switch node, and connect the edit variable output to the flow variable input at the top left of the If Switch.  Configure the If Switch such that the port is controlled by your flow variable, called 'port', and connect your inner loop to the top outport of the If switch.  Connect the bottom port to a row filter, configured to remove the 'NoData' rows from the table, and connect both to an End If node.  Hopefully the attached image also helps!

Note - you will not be able to configure nodes int he inactive branch, marked with the red corsses on the outports.  To fix this, at setup, configure the If Switch to 'both' manually, configure the rest of the nodes, and then configure the If Switch to use the flow variable!