# Re-execute db query if data are not complete

**URL:** <https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648>\
**Category:** KNIME Analytics Platform\
**Created:** [July 15, 2021, 11:47am UTC](https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648 "2021-07-15T11:47:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![d3n1s](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/db5fbb/32.png) [@d3n1s](https://forum.knime.com/u/d3n1s)\
**Post date:** [July 15, 2021, 11:47am UTC](https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648/1 "2021-07-15T11:47:11Z")

</div>

Hi guys,

I am trying to setup a workflow that pulls data from a database, checks if the data is complete and if not complete, waits for a specific time (e.g. 1h) and queries the database again. The data are uploaded into our database with certain delays, which are not constant. I have implemented this up to the ‘if switch’ that checks if data is complete or not. Is there a way to re-execute the ‘db query’ or ‘db reader’ again? Any hints or ideas are highly appreciated.

Thanks in advance, Denis

---

<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:** [July 15, 2021, 2:16pm UTC](https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648/2 "2021-07-15T14:16:22Z")

</div>

@d3n1s welcoem to the KNIME forum

I tried to ste up somthing similar a while back. Maybe you can check the discussion and the workflow collection. Also there is the [KNIME server](https://www.knime.com/knime-server) to automate things more comfortably.

> [@Start a Workflow, e. g. a database query, after a certain time](https://forum.knime.com/t/start-a-workflow-e-g-a-database-query-after-a-certain-time/30287/36):
>
> @USCHUKN1ME I tried to build a system you might be able to expand and use. The idea is to have a workflow that would iterate a number of times (v\_number\_of\_intervals) with a set interval (of seconds) between (v\_seconds\_interval) them. The workflow looks for a trigger\_file.csv if this file has changed from the last time the loop has run a component would be executed. If the file has not changed nothing would happen. Admittedly not the most elegant way but you could build a small automatic execu…

> **[use the Wait node to execute a database query at fixed times (execution...](https://hub.knime.com/mlauber71/spaces/Public/kn_example_db_wait_execute_advanced/m_025_trigger_execution~dXPATbsmwLCptMZa/current-state)**
>
> use the Wait node to execute a database query at fixed times (execution workflow) 025 - loop thru a number of times with inbetween Pl…

---

<div class="post-metadata">

**Author:** ![bruno29a](https://forum-cdn.knime.com/user_avatar/forum.knime.com/bruno29a/32/28802_2.png) [@bruno29a](https://forum.knime.com/u/bruno29a)\
**Post date:** [July 15, 2021, 2:16pm UTC](https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648/3 "2021-07-15T14:16:31Z")

</div>

Hi @d3n1s and welcome to the Community.

You probably want to use a loop in your case.

You can use the Generic Loop Start with a Variable Condition Loop End:

> **[Generic Loop Start / Variable Condition Loop End – christian.dietz](https://hub.knime.com/knime/spaces/Examples/latest/06_Control_Structures/04_Loops/13_Usage_of_Generic_Loop_Start~xgqSRhbwkfl0fMGv)**
>
> Simple workflow demonstrating the usage of the 'Generic Loop Start' node and the 'Variable Condition Loop End' node.

You start the loop, and then do the DB Query or DB Query reader inside the loop. Check if your data is complete, and set condition for the Loop end based on that check. If data is complete, loop ends. If data is not complete, loop again.

As always with this type of loop, you should have a fail-safe and add an additional condition, such as if loop has iterated 5 or 10 times, you have to throw an error, or it could go to infinite loop

---

<div class="post-metadata">

**Author:** ![d3n1s](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/db5fbb/32.png) [@d3n1s](https://forum.knime.com/u/d3n1s)\
**Post date:** [July 15, 2021, 2:47pm UTC](https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648/4 "2021-07-15T14:47:39Z")

</div>

Hi guys,

thanks a lot for your answers. I was thinking of using a loop indeed, just was not sure which exact node to use. This is definitely helpful.

Regards,  
Denis

---

<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:** [January 14, 2022, 2:47am UTC](https://forum.knime.com/t/re-execute-db-query-if-data-are-not-complete/34648/5 "2022-01-14T02:47:50Z")

</div>

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