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 PTC Community Badges. Engage with PTC and see how many you can earn! X

MSSQL Extension mapping table name syntax error

ssriuaipornchai
13-Aquamarine

MSSQL Extension mapping table name syntax error

I create SQL command for purge all data in table.

 

DELETE FROM [[tableName1]];

[[tableName1]] is the input table.

 

When execute this service. It error like below code

Unable to Invoke Service purgeTable on MTH.FC2.ASSY.SQLConnector : Execute Update failed: com.microsoft.sqlserver.jdbc.SQLServerException: Must declare the table variable "@P0".

But, If I put the table name inside the service code. It can execute without error.

DELETE FROM test;	

 

How I should to do ?

2 REPLIES 2

Hello,

 

Take a look at this article, and in particular check Example 3, it should do the trick. Also you may find <<tableName>> to work -- it does simple string replacement, but I'm not sure if it still works in the recent versions of ThingWorx and with MS SQL.

 

...and then forget about it, because it is a very bad idea, unless you are OK about somebody dropping your entire database one day. If you really need to do it, then wrap it into some parameter-sanitizing code and make sure that only system admins can execute it.

 

Regards,
Constantine

It's not workingUntitled.png

Announcements


Top Tags