Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
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 ?
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