Syntax for deleting records from table using sql inside of TI job
Posted: Wed Jul 12, 2023 5:06 pm
After multiple syntax fails, I have been able to load an external table using TM1 with the following syntax. However, I continue to get fails when trying to delete the data from the table. I have verified that my account has delete access because I am able to remove all of the data from the table with a simple Delete sql function but, I want to be able to select the items I want to remove.
Syntax that works:
ODBCOpen (Source, ClientName, Password);
sSQL = 'INSERT INTO "TableName" VALUES(''' | tblcolumnvar1 |''','''| tblcolumnvar2 |''','''| tblcolumnvar3 |''','''| tblcolumnvar4 |''','''| tblcolumnvar5 |''','''| tblcolumnvar6 |''','''| tblcolumnvar6 |''','''| tblcolumnvar7 |''','''| tblcolumnvar8 |''','''| tblcolumnvar9 |''','''| tblcolumnvar10 |''','''| tblcolumnvar11 |''','''| tblcolumnvar12 |''','''| tblcolumnvar13 |''','''| tblcolumnvar14 | ''')' ;
ODBCOutput ( Source, sSQL);
_______________________________________________________________
Syntax that fails:
ODBCOpen (Source, ClientName, Password);
sSQL = 'DELETE FROM "TableName" WHERE( Period = ( '| tblcolumnvar1 |' AND '| tblcolumnvar2 |' ))';
ODBCOutput ( Source, sSQL);
Syntax that works:
ODBCOpen (Source, ClientName, Password);
sSQL = 'INSERT INTO "TableName" VALUES(''' | tblcolumnvar1 |''','''| tblcolumnvar2 |''','''| tblcolumnvar3 |''','''| tblcolumnvar4 |''','''| tblcolumnvar5 |''','''| tblcolumnvar6 |''','''| tblcolumnvar6 |''','''| tblcolumnvar7 |''','''| tblcolumnvar8 |''','''| tblcolumnvar9 |''','''| tblcolumnvar10 |''','''| tblcolumnvar11 |''','''| tblcolumnvar12 |''','''| tblcolumnvar13 |''','''| tblcolumnvar14 | ''')' ;
ODBCOutput ( Source, sSQL);
_______________________________________________________________
Syntax that fails:
ODBCOpen (Source, ClientName, Password);
sSQL = 'DELETE FROM "TableName" WHERE( Period = ( '| tblcolumnvar1 |' AND '| tblcolumnvar2 |' ))';
ODBCOutput ( Source, sSQL);