# How could I loop a db query reader dependent on entire workflow

**URL:** <https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810>\
**Category:** KNIME Analytics Platform\
**Tags:** database\
**Created:** [November 26, 2025, 8:06pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810 "2025-11-26T20:06:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zenster](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/cdc98d/32.png) [@zenster](https://forum.knime.com/u/zenster)\
**Post date:** [November 26, 2025, 8:06pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/1 "2025-11-26T20:06:51Z")

</div>

I’m trying to query a database table and derive a value from that table example a Name. I want the rest of the workflow to operate as usual with it’s built in loops and at the end when it’s completed it’s run, I want it to re run the db query reader node at the beginning. Picture for reference.

---

<div class="post-metadata">

**Author:** ![zenster](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/cdc98d/32.png) [@zenster](https://forum.knime.com/u/zenster)\
**Post date:** [November 26, 2025, 9:06pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/2 "2025-11-26T21:06:53Z")

</div>

> **Summary**
>
> This text will be hidden

 ![IMG_3947](https://forum-cdn.knime.com/uploads/default/original/3X/f/0/f01289a677f372aa9a7f4b75f3e70f0ac05d52c4.jpeg)

The top query gets a name to use as a variable for the row filter and the bottom part of the workflow is the actual workflow I want to run for that one name. However, when that bottom workflow finishes running completely, I want the top db query reader to get a new name to run the workflow again until there are no new names.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [November 26, 2025, 11:25pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/3 "2025-11-26T23:25:19Z")

</div>

@zenster Maybe you can take a look at this article and the examples provided

[https://medium.com/low-code-for-advanced-data-science/knime-paths-and-loops-automate-everything-213455788685](https://medium.com/low-code-for-advanced-data-science/knime-paths-and-loops-automate-everything-213455788685)

---

<div class="post-metadata">

**Author:** ![zenster](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/cdc98d/32.png) [@zenster](https://forum.knime.com/u/zenster)\
**Post date:** [December 1, 2025, 9:55pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/4 "2025-12-01T21:55:33Z")

</div>

Thank you! However, there seems to be no easy way to get the actual db query reader node to loop with any of the solutions in this article. Could be my lack of understanding but i’ve tried multiple methods to loop the db query reader to run after the main workflow runs and still no luck.

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [December 2, 2025, 7:39am UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/5 "2025-12-02T07:39:41Z")

</div>

> [@zenster](#):
>
> actual db query reader node to loop with any of the solutions

You most likely will have to think about where which operation should take place. You can extract the list of items you want to loop over from a database and then feed them one by one via Flow Variables into another DB Query node to do the jobs. You will have to make sure how to close the loop. You can either just close it with a Variable Loop end or collect information.

> **[An example of combining SQL database, loop and case switch – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/kn_example_switch_case_store_file_sql~k2DRahhctYmHk-zg/current-state)**
>
> An example of combining SQL database, loop and case switch there are 10 chunks in the database. some of them have fault=1 lines some do not. The chunks with fa…

---

<div class="post-metadata">

**Author:** ![zenster](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/cdc98d/32.png) [@zenster](https://forum.knime.com/u/zenster)\
**Post date:** [December 2, 2025, 9:41am UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/6 "2025-12-02T09:41:25Z")

</div>

Yes. I’m able to get a list of the items I want to iterate over. The main struggle is that list could change after the workflow is initiated. The query checks for a specific category item being uploaded to the database. If it’s not being uploaded it will grab a random value to filter on. Then continue with the main workflow. It seems there’s no simple way to keep re-running that db query reader for an updated value.

The purpose of this is also so that multiple users running the workflow for the same database won’t overlap uploading data for the same category

---

<div class="post-metadata">

**Author:** ![takbb](https://forum-cdn.knime.com/user_avatar/forum.knime.com/takbb/32/57077_2.png) [@takbb](https://forum.knime.com/u/takbb)\
**Post date:** [December 2, 2025, 12:26pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/7 "2025-12-02T12:26:30Z")

</div>

Hi @zenster,

> [@zenster](#):
>
> there seems to be no easy way to get the actual db query reader node to loop

The DB Query Reader node itself cannot “loop”, but it can be placed inside a loop.

If you want the DB Query Reader to execute again, you’ll need to put that inside a loop, and currently in your screenshot it isn’t, so it will execute just the once. Are you asking how to structure it so that it is also inside a loop of its own?

When you say you’re able to get a list of the items to iterate over, but that the list could change after the workflow is initiated, what determines the change of list, and how should the workflow be handling that eventuality?

Without actually knowing what your two separate DB Query Reader nodes are actually retrieving (or the conditions) it’s difficult to second guess exactly what workflow structure you will need, other than that you are likely to need at least one additional loop outside of at least one of the DB Query Reader nodes.

As you have mentioned that the DB Query Reader should “get a new name to run the workflow again until there are no new names”, I’m thinking it could be that you want to add a recursive loop, or maybe simply a variable condition loop, either of which could end the loop when there is no more data, but it really depends on exactly how the different DB Query Reader nodes are to interact.

Can you give us more description or insight about what each DB Query Reader node does? Does the lower one, for example only run once, or should that also execute again for each execution of the upper DB Query Reader?

---

<div class="post-metadata">

**Author:** ![zenster](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/z/cdc98d/32.png) [@zenster](https://forum.knime.com/u/zenster)\
**Post date:** [December 2, 2025, 3:42pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/8 "2025-12-02T15:42:46Z")

</div>

> [@takbb](#):
>
> If you want the DB Query Reader to execute again, you’ll need to put that inside a loop, and currently in your screenshot it isn’t, so it will execute just the once. Are you asking how to structure it so that it is also inside a loop of its own?

Yes. I can’t understand how to structure it. I would like the db query reader on the top of the screenshot to re-query after the bottom workflow is complete.

> [@takbb](#):
>
> When you say you’re able to get a list of the items to iterate over, but that the list could change after the workflow is initiated, what determines the change of list, and how should the workflow be handling that eventuality?

It’s not a list. The top query checks what is already being uploaded let’s say a name on a list. The way the bottom workflow works is at that row filter it will use that name because it’s not being uploaded or has been uploaded.

> [@takbb](#):
>
> Without actually knowing what your two separate DB Query Reader nodes are actually retrieving (or the conditions) it’s difficult to second guess exactly what workflow structure you will need, other than that you are likely to need at least one additional loop outside of at least one of the DB Query Reader nodes.
> 
> As you have mentioned that the DB Query Reader should “get a new name to run the workflow again until there are no new names”, I’m thinking it could be that you want to add a recursive loop, or maybe simply a variable condition loop, either of which could end the loop when there is no more data, but it really depends on exactly how the different DB Query Reader nodes are to interact.
> 
> Can you give us more description or insight about what each DB Query Reader node does? Does the lower one, for example only run once, or should that also execute again for each execution of the upper DB Query Reader?

yes the top query is getting one name that doesn’t exist in the “upload table” and therefore we can use it for the process below. The bottom query only needs to be run once. It’s getting all the relevant data for all possible names. After it’s filtered there is already a recursive loop and a group loop. I will post the rest of the workflow if it will help.

Also thank you for you reply

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [March 2, 2026, 3:43pm UTC](https://forum.knime.com/t/how-could-i-loop-a-db-query-reader-dependent-on-entire-workflow/90810/9 "2026-03-02T15:43:39Z")

</div>

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