cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Is there a way to pass dynamic table name to sql query ?

ChahatGupta
8-Gravel

Is there a way to pass dynamic table name to sql query ?

Hi,

I want to pass the table name dynamically to SQL query in thingworx version 8.5.5

Is it possible ?

Thanks,

Chahat

1 ACCEPTED SOLUTION

Accepted Solutions

If you pass the parameter with <<param>> instead of [[param]] it should work.  E.g.

 

select * from <<table_name>>

View solution in original post

4 REPLIES 4

I am not sure if you will be able to pass the table name as an input to a SQL query service. But you can wrap different condition sql query service in a JS service using if/else. Like if the input is TableA, call the select * from TableA or else if it is TableB call the select * from TableB service. The Grid can handle dynamic data shape as well.

 

 

 

In JDBC passing the table name as an SQL parameter is not possible.

You can create your own stored procedure for which there are examples in stackoverflow, but it leaves you open to SQL injection - and you don't want that.

I would follow my colleague's suggestion

If you pass the parameter with <<param>> instead of [[param]] it should work.  E.g.

 

select * from <<table_name>>

It works.

 

Thanks!

Top Tags