Forum Discussion
KurtMayer
2 years agoContributor
I need to delete a single Error Log record from the System table "ErrorLog"
I need to delete a single record in the Error Log but my Data Adapter won't let me, complaining about "unsafe SQL statements". In a rather bone-headed move, while developing a BR, I accidentally wro...
- 2 years ago
Hey Kurt
You can't execute an insert/delete statement from a SQL adapter. You'll need to do this from a Business Rule.
I normally just create an Extender Business Rule. Something like this should work:
Namespace OneStream.BusinessRule.Extender.ExecuteSQL Public Class MainClass Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object Try 'Create connection to Framework database Using dbConn As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si) 'Execute SQL BRApi.Database.ExecuteActionQuery(dbconn, "UPDATE ErrorLog Set Description = 'log entry trimmed' Where UniqueID = 'bb5158a6-aae9-471c-b883-edddc8640a5e'", False, True) End Using Return Nothing Catch ex As Exception Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) End Try End Function End Class End NamespaceThen Execute it using the play button:
Regards,
Mark
MarkBird
2 years agoContributor III
Hey Kurt
You can't execute an insert/delete statement from a SQL adapter. You'll need to do this from a Business Rule.
I normally just create an Extender Business Rule. Something like this should work:
Namespace OneStream.BusinessRule.Extender.ExecuteSQL
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
'Create connection to Framework database
Using dbConn As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
'Execute SQL
BRApi.Database.ExecuteActionQuery(dbconn, "UPDATE ErrorLog Set Description = 'log entry trimmed' Where UniqueID = 'bb5158a6-aae9-471c-b883-edddc8640a5e'", False, True)
End Using
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
Then Execute it using the play button:
Regards,
Mark
Related Content
- 2 months ago
- 1 month ago
- 2 years ago
- 1 year ago