'Getting the ID of an inserted record instead of a "TTCError" from Oracle using .Net

We are updating an older application to use the "new" Oracle.ManagedDataAccess instead of the locally installed Oracle Client. But since then a simple statement like below. The ID column is filled with a trigger and a sequence.

    INSERT
      INTO "SOME_TABLE" ("value1", "value2")
      VALUES(:p, :p)
      RETURNING "ID" INTO :LASTID

But this now results in a "TTC Error" with no inner exception nor any other details in the exception. In the exception the stacktrace is only the single call to "OracleInternal.TTC.OraBufReader.ReadLengthAndData(Byte repOffset, Byte typeRep, Byte[]& dataBuffer, Int32& offset, Int32& bufLength, Boolean IgnoreData)".

The call stack in the debugger when this exception occurrs is:

 Oracle.ManagedDataAccess.dll!OracleInternal.TTC.OraBufReader.ReadLengthAndData(byte repOffset, byte typeRep, out byte[] dataBuffer, ref int offset, ref int bufLength, bool IgnoreData)
 Oracle.ManagedDataAccess.dll!OracleInternal.TTC.MarshallingEngine.BufferToValue(byte repOffset, bool bIgnoreData)
 Oracle.ManagedDataAccess.dll!OracleInternal.TTC.TTCExecuteSql.ReceiveExecuteResponse(ref OracleInternal.TTC.Accessors.Accessor[] defineAccessors, OracleInternal.TTC.Accessors.Accessor[] bindAccessors, bool bHasReturningParams, ref OracleInternal.Common.SQLMetaData sqlMetaData, OracleInternal.Common.SqlStatementType statementType, long noOfRowsFetchedLastTime, int noOfRowsToFetch, out int noOfRowsFetched, ref long queryId, int longFetchSize, long initialLOBFetchSize, long[] scnFromExecution, bool bAllInputBinds, int arrayBindCount, ref OracleInternal.ServiceObjects.DataUnmarshaller dataUnmarshaller, ref OracleInternal.TTC.TTCExecuteSql.MarshalBindParameterValueHelper marshalBindParamsHelper, out long[] rowsAffectedByArrayBind, bool bDefineDone, ref bool bMoreThanOneRowAffectedByDmlWithRetClause, ref System.Collections.Generic.List<OracleInternal.TTC.Accessors.TTCResultSet> implicitRSList, bool bLOBArrayFetchRequired)
 Oracle.ManagedDataAccess.dll!OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery(string commandText, Oracle.ManagedDataAccess.Client.OracleParameterCollection paramColl, System.Data.CommandType commandType, OracleInternal.ServiceObjects.OracleConnectionImpl connectionImpl, int longFetchSize, long clientInitialLOBFS, OracleInternal.ServiceObjects.OracleDependencyImpl orclDependencyImpl, out long[] scnFromExecution, out Oracle.ManagedDataAccess.Client.OracleParameterCollection bindByPositionParamColl, ref bool bBindParamPresent, out Oracle.ManagedDataAccess.Client.OracleException exceptionForArrayBindDML, Oracle.ManagedDataAccess.Client.OracleConnection connection, ref Oracle.ManagedDataAccess.Client.OracleLogicalTransaction oracleLogicalTransaction, bool isFromEF)
 Oracle.ManagedDataAccess.dll!Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()

An (very old) post remarked that this happened when using a trigger on a table, so I had a DBA create a table with the same structure but than with an identity-column. But this did not change anything, still the informative message "TTC Error".

We are using .Net Framework 4.6.2 and Oracle.ManagedDataAccess v19.12.0. The database (as read from v$version) is: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.11.0.0.0

Edit: Updating the library to v19.13.0 did not resolve this issue.



Solution 1:[1]

Never found out what the problem was. I've rewritten this piece of code and one thing I've changed, was that I now used named parameters... and gone was this exception. A little underwhelming, but the problem is gone. ?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SvenL