Hi All
I am currently looking at a connector, that when updated is using protocol.AddRow, this is going to lead to a new entry added to the table everytime.
Is there a method that can be used to update a row based on primary key index if it already exists and if it doesn't, then add a new row?
Thanks
Hi Ryan,
The most basic way for you to achieve what you are after is to use a combination of 3 calls
And you would do something like:
if(protocol.Exists(...){
protocol.SetRow(...)
}else{
protocol.AddRow(...)
}
If you want to use the SLProtocolExt interface, you could use this other SetRow method | DataMiner Docs that would look something like this
protocol.MyTableName.SetRow(..., true)
Where the true boolean value indicates to DataMiner to create a row if it does not exist for that primary key.
As an addendum, if your are processing multiple rows at once you could also look into the FillArray method https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Scripting.SLProtocol.FillArray.html?q=fillarray#Skyline_DataMiner_Scripting_SLProtocol_FillArray_System_Int32_System_Collections_Generic_List_System_Object____Skyline_DataMiner_Scripting_NotifyProtocol_SaveOption_
The SaveOption argument will let you select if you want to completely override the entire content of the table (Full) or leave what you do not provide untouched (Partial)
https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Scripting.NotifyProtocol.SaveOption.html