There are a bunch of posts on dynamic queries.
I made this post to help myself understand and keep this straight some.
-I bound a dropdown to a Querystring paramater to switch which db table my perspective table object displayed.
-then I decided that I should find out how to make dynamic queries for machines
I gathered that I needed to set my parameter type to Querystring to make the table selection dynamic, which Querystring type is susceptible to injection attack, so I bound the perspective table object data to a dropdown prop value.
I right click to pick to put the parameter into my query after "From", choosing insert parameter. This was in the named query authoring.
I made a table and a dropdown on a perspective page.
I made two options on the dropdown.
Each value is the name of a table.
Each label is the short name of the machine.
In the table, I set the named query binding for the data.
In the parameter I click the function symbol, then pick the prop value of the drop down.
It worked. Switching between the two options in the dropdown changed my table between the tables for the two different machines.
now it seems natural to want to make the queries (columns, table, when, group by, and order by) into more dynamic sanitized selectable values
I see so many posts about this though.
(queries are so useful, and injection attacks are so bad)
I don't have much experience with :
system.db.runPrepUpdate()
or
system.dataset.toPyDataSet()
If I understand, Prepupdate can be used to sanitize inputs for queries in script. However, the table and columns would not be dynamic because the question mark place holder is excluded in SQL standard.
toPyDataSet is for getting datasets from tables to manipulate in scripts mostly.
Querystring parameters in the named queries can modify the columns and table name.
Using querystring parameters is the main way to develop dynamic queries I think.
Right now, I have my test page with a table that uses a dropdown to change between which machine it is getting the data from.
If I want to switch which data is being gathered, I need to make the columns into querystrings, and make some kind of picker or dropdown for this I think.
What is recommended for this?
Going to research Perspective tree
I think I could make radial select buttons next to text work
I am not sure.
The number of columns someone will want would be dynamic.
I don't know how to setup dynamic bindings though.
still trying to figure it out. I found a couple posts that looked similar.
Not sure though.