Indirect Query Selection For Tables In Ignition Perspective

I have a many different queries that follow the same file structure and name, just a different ending number. I was wondering if I could set a parameter value as the path to change the value of a table to parse switch the query that is displayed in the table.

I was hoping to do this through a dropdown to select and change a parameter ideally.

Do you want to dynamically pick the table? Or just a different parameter in the query?

Can you show your query?

I would like to dynamically pick the table by changing the query. This is the format for each of the queries, where the '%1016%' just has a number"

Changing the query dynamically was my first idea, I'm open to other ways of doing this, was just what seemed most viable to me at first glance.

So you want the like statement to be a parameter?

Or the table in the from statement? What you want and what you said are two different things.

Table From The Statement

You have to use a query string in your named query.

They are not sanitized, so risk of SQL injection is high.

Hi,

If you want to avoid using QueryString and you've already created all your SQL queries, you could do with an expression binding and the runScript function.

Something like this :

The view.custom.dropDownValue is a binding referencing the current value of the dropdown.
Your dropdown values would have to be "Alarms/Block A/Station/AlarmJournalSta1016", etc etc.

If you have more operations to perform after fetching the data, consider moving the whole script into a script library, and calling the function in the runScript instead.

1 Like