Make dynamic report query with table name

Dears,
I have tens of circuit breakers tables ,I want to build a report viewer that shows the data depending on a chosen CB from a drop down list.

I tried to make a report query with dynamic table name but it is showing an error and can not procced.

Any advices?

Regards,


Question mark substitutions can only provide values to queries, not structural items like table or column names.

If all the tables have the same structure, why do you not have a single table with an indexed column to show what machine a particular row belongs to? Then you can put that (as a value substitution) in a WHERE clause.

2 Likes

Crop the images, man! Crop the images! 80% of them is empty. At least resize them. You can also use tools like Snagit (paid) or https://greenshot.org (open source) to do nice stuff. They're both for Windows but other flavours will be available.

1 Like

While, @pturmel's response is definitely the preferred and best practice. Should you be in a position where you can not modify the DB. Then the best way to accomplish your goal would be to use a script data source with system.db.runPrepQuery() where you build the query string dynamically inserting the needed table name.

4 Likes

Thanks @pturmel ,I think my power management system is completed now :sunglasses:

1 Like