Page 1 of 1

Doing Inserts,Updates and Delete in Database tables using TI

Posted: Mon Dec 27, 2010 9:32 pm
by vinnusea
Hi Guys,
I have a excel source and using this with an ODBC and writing SQL query to pull data from Excel sheet and
My task is to do inserts update and delete a table present in SQL Server data base.
I have done lot of Inserts before using "ODBCOutput function" But how can i do Insert and update by comparing the columns?? like PK of Source is Null then Insert and if PK of target is null then delete and else compare each column with Target column and Update..

can you guys tell me any idea i can follow??

Thank you....

Re: Doing Inserts,Updates and Delete in Database tables usin

Posted: Thu Dec 30, 2010 7:04 am
by Martin Ryan
If I understand correctly what you're trying to do then you might find that you need several TI processes. The first will process the main table and then depending on what it finds in each row it will call other TI processes to do what it is you want to do. For example the Data tab of the first TI process, which reads from the main table, might look like this

Code: Select all

if(nData=someTest1);
  ExecuteProcess('DeleteRowProcess', 'pParm1', vVar1, 'pParm2', vVar2);
elseif(nData=someTest2);
  ExecuteProcess('UpdateRowProcess', 'pParm1', vVar3, 'pParm2', vVar4);
elseif(nData=someTest3);
  ExecuteProcess('InsertRowProcess', 'pParm1', vVar5, 'pParm2', vVar6);
else;
  SomeCatchAllCode;
endif;
HTH,
Martin