Executing a set of nodes only if records are found

I am required to execute a certain set of nodes if and only if the previous step produces 1 or more records. If no records are created then the second set of steps should not be carried out.

Here, attached, is a workflow that kind of looks like what I have.
I have attached sample input xlsx files to give an idea.
In my real workflow the xcel sheet input is actually a db query.

The thing is of the two inputs, the second may or may not have records.

The first branch creates an xml output
The second branch creates an xml output too.
Then the workflow concatenates the two sources to create a single consolidated xml output.
As mentioned, the second input branch may occasionally have no records.
In such a situation, the output of the workflow is the output of the first branch. No second branch. Second branch should be concatenated if and only if records are found in it.

Currently, when I face such a situation, I get that warning exclamation mark and the whole workflow fails.
I was looking for some sort of a ‘if then else’ block node that would help me achieve this!
I’m sure there is a way…just need to be pointed in the right direction.

Thanks in advance @AnotherFraudUser for helping with the previous steps.
I was able to successfully implement them!

XML Output.knwf (23.0 KB)

Input Table01.xlsx (9.7 KB) Input Table02.xlsx (10.4 KB)

Hi @Shai,

Although it looks like the branch does not affect the whole process you can use the Empty Table Switch to skip nodes.

:blush:

4 Likes

Oh! as in mimic the columns.
So the workflow can continue to execute without any rows.

So in your view, I would create the empty table first then populate the table with the query data?
So even if the query returns zero records, the table structure will be there and will allow the workflow to keep progressing. Is that the way you are suggesting?

I’ll try it.

Hi @Shai,

so if I got it right Empty Table Switch node should go before Column to XML node and additionally you need to add End IF prior to concatenation. See screenshot:
SkipEmptytable

Br,
Ivan

2 Likes

For now, I changed the way I had designed the source query. I am stronger at sql and table manipulation at this stage than in Knime. So got by that way for now.

But I shall remember this suggestion.

Its all a learning curve for me. I’m very new to Knime.
Thanks for suggestion. I truly appreciate the intent.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.