SQL Query binding, when its executed ? What triggers that?

Hi, I am trying to understand SQL Query binding. I could not find the first and most important thing for me and that is when I use Query binding to lets say Data in table, how do I know when this query is executed ? Its looks like everything I click, or I load the page the query fires. I would like to fire it only when I have all 4 parameters for named query filled. I noticed that the query fires when one of those four parameters is changed ? To me it looks not very efficient

A query binding will update when

  • the component with the query binding loads.
  • again after N seconds if polling is configured for N seconds
  • whenever a parameter of the query changes (if the query uses parameters)

If you parameterize the query with four different values, then wouldn’t you want it the result set to change whenever you update any of the four values? If you don’t want the binding to update for every change to any of the values, perhaps you could get the results as part of a scripting call and just write the result to your table.

Example:
Suppose you have a table, and four text fields which each represent a parameter of your query. Now place a button. Configure an onClick or onActionPerformed Event for the button and include a Script Action which use runPrepQuery along the lines of

self.getSibling("MyTable").props.data = system.db.runPrepQuery("select something from MyTable where a=?, b=?, c=? d=?", [tfValue1, tfValue2, tfValue3, tfValue4], "MyDatabase")
2 Likes

You might also find this system function handy if you want to exert more control on the refresh of a given dataset binding: system.db.refresh - Ignition User Manual 8.1 - Ignition Documentation

1 Like