I think you need to perform your processing to construct the query to be sent to DB prior to using the sqlSelect() function in the script.
For example, if a static SQL expression is as follows:

The type of table can be parameterized by supplying the key in an input field:

The DB Execute node script is configured as follows to incorporate the key binding into a string-valued expression that can then be used in the sqlSelect() function.
