SQL Table Insert Not adding all Records
HI All,
I'm running into an issue when running a Finance Business Rule, essentially this rule creates a data buffer and loops through where U8 member is not 0. From here we have a SQL statement where we're inserting these dimensions and the Business Unit which is derived from the Workflow Text field. Whenever a end user presses the button it should trigger this DM job and Business Rule to delete an existing records for this BU in the table and then add all the records again.
The issue is however that in this case that we're expecting to see 112 records but only seeing around 40. I wrote to the error log and see all the row records of 112, however when inserting into the table we only get around 40, sometimes even less. From what I compared looking at all 112 records vs the 40 in the table, I noticed that from the error most of the records that are the looping through last are being added to the table, but only a few from the beginning. It's almost as if these records are being over written. All these rows are unique, although some rows have everything the same besides a profit center (Entity field). Any idea of why this would be or what could be done?
Dim valueList As List(Of String) = New List(Of String) Dim x As Integer = 0 For Each Cell As DataBufferCell In SrcDataBuffer.DataBufferCells.Values ' Execute If Allocation percentage Is Not equal To 0 If Cell.CellAmount <> 0 Then x += 1 sAcct = Cell.DataBufferCellPk.GetAccountName(api) sUD1 = Cell.DataBufferCellPk.GetUD1Name(api) sFlow = Cell.DataBufferCellPk.GetFlowName(api) sUD2 = Cell.DataBufferCellPk.GetUD2Name(api) sUD4 = Cell.DataBufferCellPk.GetUD4Name(api) valueList.Add($"('{sqlentity}','{sEntitymember}', '{sUD4}', '{sFlow}', '{sUD2}', '{sUD1}', '{sAcct}', {Cell.CellAmount})") End If Next Dim insertValues = String.Join(", ", valueList) Dim sql As String = $"INSERT INTO XFT_BSM_Mapping_Total$ ([BU], [Entity], [BSM_Account], [BSM_Measure], [Responsibility_Center], [Company_Code], [Account],[Allocation_Percentage]) VALUES {insertValues}" brapi.ErrorLog.LogMessage(si,x) Using dbConn As DBConnInfo = BRAPi.Database.CreateApplicationDBConnInfo(si) BRAPi.Database.ExecuteSql(dbConn , sql, True) End Using