SQL Query with Parameters, postgresql 15, syntax error

Hello,

I am querying a postgres db and trying to add a parameter, which isn't working. I'm getting the syntax error that I've attached a pic of. I've followed the instructions in the manual, but still no data. I feel like this must be something simple I'm missing.
Snag_240eca85
Snag_240ee1c6
Snag_240eef43

In standard SQL queries, like named queries, parameters cannot be used to substitute structural elements of a query - only parameters within e.g. a WHERE clause. You can technically get around this limitation with the 'Basic SQL Query' type: Basic SQL Query | Ignition User Manual, but it's better overall to not have a need for dynamic queries in the first place.

2 Likes

Thanks for the response. I need to be able to select between a lot of different db tables, not sure of another way to do that.

I would use a scripted data source and use that to build the query dynamically, then execute it using system.db.runPrepQuery()

Is your question actually related to this topic? If not, delete this and start a new topic for your question. Then provide more information (actual SQL and script content).