Skip to main content
1-Visitor
August 23, 2018
Question

queries

  • August 23, 2018
  • 1 reply
  • 2768 views

Hello community,

I am just starting with thingworx and i wanted to know how to write queries (using SQL) and not Javascript to fetch some entries from a datatable created previously on thingworx

1 reply

17-Peridot
August 24, 2018

Hi,

 

To do this , you should create a new service, when window opens, you have near New Service a dropdown list with: Local (Javascript), SQL( Query), SQL (Command). You should choose SQL (Query) or SQL(Command). Then , you can start writing your SQL query.

For differences between the 2 options are explained here: Difference between SQL (Query) and SQL (Command) service types in ThingWorx

 

Best regards,

Raluca Edu

1-Visitor
August 24, 2018

Well actually to query data from ThingWorx Storage (ValueStreams, Streams and DataTables) you can't use SQL, you have to rely on ThingWorx querying Snippets. The other way around it's not recommended and it isn't as easy as pointed out by raluca_edu (an data storage for ThingWorx object may change between TW Storage versions and it will fail).

i_abidi1-VisitorAuthor
1-Visitor
August 24, 2018

CarlesCol, so if i wanted to perform a query on a datatable in Thingworx and let's say i wanted to select the entries HAVING certain conditions, i can not do it unless it's on an SQL server ? or i can still create a javascript (not so good with javascript) service to do the query?