Skip to main content
1-Visitor
November 21, 2018
Question

SQL Query: Assignment of value of an input variable in to internal temporary variable

  • November 21, 2018
  • 1 reply
  • 2999 views
Spoiler
SQL Query: Assignment variable

Hello all !!!!

I have problems with assignment of value of an input variable to temporary variable. I create service with SQL Query. Added an input variable [[container]] with type of data a string. In assignment attempt: set @Container=[[container]] - the compiler ceases to highlight syntax and execution happens to an error. At execution of any command as soon as I insert an input variable, [[.....]] check of syntax shows that it is not right.

image.png

Whether somebody knows in what an error? In SQL Managment studio everything works.

1 reply

22-Sapphire I
November 21, 2018

My best guess is that the compiler within composer isn't set up to recognize that syntax as a possible parameter substitution.

You can try the more dangerous and more powerful << >> which is a string substitution and shouldn't cause any complaints but exposes you to potential SQL Injection

1-Visitor
November 22, 2018

You suggest to write set @container=<<container>>; instead of
set @container=[[Container]] ?

22-Sapphire I
November 27, 2018

Correct!

For input parameters into a service standard when you bring it in it will be [[ ]] which is Parameter substitution but << >> is String substitution, so potentially the service is more 'forgiving'

If it still doesn't accept that, then you may have to go the full 'build your query as a string' route and then execute it with <<YourFullSQLStringHere>> approach

 

Here is an article on it: https://community.ptc.com/t5/ThingWorx-Developers/How-can-I-execute-a-sql-query-constructed-dynamically/m-p/501798