runtime: ODBC Arithmetic overflow error Accessing AS400 DB2 (Update, Delete, Insert)
We are trying to hit our AS400 running a DB2 instance. When we run a OdbcCommand.ExecuteNonQuery() for select, everything works no issue. However, when executing a simple update, or delete command, we encounter the below error. Our current workaround is to just squish all arithmetic errors out of our execute command, which is unacceptable.
Arithmetic operation resulted in an overflow.
at System.Data.Odbc.OdbcDataReader.FirstResult()
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteNonQuery()
We are using VS 2017 with netcore 2.2
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
@BockTim91, could you please share how are you connecting to as400? I am using .net5 and IBM.data.DB2.core package to connect to my iSeries database. had no luck so far.
Experiencing the same issue with Vertica DB. When ODBC client is in 64 bit (.NET 5) and rows affected > Int32.MaxValue, overflow exception is thrown. I believe @Clockwork-Muse is exactly right in his analysis of the root cause https://github.com/dotnet/runtime/issues/31533#issuecomment-557211264
Unfortunately recent optimization done in .NET 6 preview branch - https://github.com/dotnet/runtime/commit/3d200308e1c9eb8daabd0498d7a2ee02635452b1 - will not solve the issue:
checked((int)l)
is removed, but ToInt32() called on IntPtr will throw OverflowException still.We are building x86 target for now, just to overcome that issue. I guess getting some negative int for rows affected instead of the real count (> int.MaxValue) would be better then an overflow exception.
Turns out I had an out of date IBM Client Access ODBC driver 13.0.1.0.
I downloaded and installed the latest AS400 Client Access service pack si68573 from IBM and I think it may have fixed the problem.
The IBM i Access ODBC drivers versions are now: