Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy I get OracleTruncateException with ODP.NET OracleDataAdapter but not with System.Data.OracleClient's adapter when DbDataAdapter.Update called?
    primarykey
    data
    text
    <p>I do the following:</p> <pre><code>protected int CreateComponent(DbConnection cnctn, string tableName) { int newId; DbCommand selectCmd = _provFactory.CreateCommand(); selectCmd.Connection = cnctn; selectCmd.CommandText = string.Format( "SELECT * FROM {0} WHERE ID = (SELECT MAX(ID) FROM {0})", tableName); DbDataAdapter dataAdapter = _provFactory.CreateDataAdapter(); dataAdapter.SelectCommand = selectCmd; ... // create Insert/Update/Delete commands with a builder for the data adapter ... dataAdapter.Fill(_dataSet, tableName); newId = Convert.ToInt32(_dataSet.Tables[tableName].Rows[0]["id"]) + 1000000; DataRow newRow = _dataSet.Tables[tableName].NewRow(); newRow.ItemArray = _dataSet.Tables[tableName].Rows[0].ItemArray; newRow["ID"] = newId; _dataSet.Tables[tableName].Rows.Add(newRow); } </code></pre> <p>This works perfectly for OleDb and System.Data.OracleClient. However with Oracle.DataAccess.Client's provider I get:</p> <pre><code>Oracle.DataAccess.Types.OracleTruncateException (16550) </code></pre> <p>with text truncated result originating from:</p> <pre><code>at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors at System.Data.Common.DbDataAdapter.UpdatedRowStatus at System.Data.Common.DbDataAdapter.Update at Oracle.DataAccess.Client.OracleDataAdapter.Update at System.Data.Common.DbDataAdapter.UpdateFromDataTable at System.Data.Common.DbDataAdapter.Update </code></pre> <p>The tables I get this are big tables that other contains 61 fields. The types of all fields are limited to:</p> <pre><code>VARCHAR2(different lenghts) VARCHAR2(different lenghts) NOT NULL FLOAT(126) NOT NULL NUMBER NOT NULL DATE </code></pre> <p>Edit to prevent too many comments:</p> <p>-I cannot change the datatype or anything in the database.</p> <p>-In DataRow these FLOAT(126) columns have data type System.Decimal (like when using other providers)</p> <p>-Unlike I stated before: ID is not primary key. It's unique index. Table does not have primary key (as Oracle definition) I have to admit that I thought that unique index is primary key which may sound preposterous for people familiar with Oracle. Anyway I make only Insert of 1 row. I haven't tried to handbuild Insert-command which I'll do in a bit. Command builders should handle tables without PK (http://msdn.microsoft.com/en-us/library/tf579hcz.aspx: "The SelectCommand must also return at least one primary key or unique column.") </p> <p>-This works also with ODP.NET/Oracle.DataAccess.Client if:</p> <ul> <li>I give all the FLOAT(126)-columns value 0 before the method's last row. Even with giving value 1 or 2 to any raises same exception when DbDataAdapter.Update is called.</li> </ul> <p>or </p> <ul> <li>I create the DbDataAdapter.Insertommand myself and there's only insert (like code above) when DbDataAdapter.Update is called. When I cmd build myself I give DbParameter.DbType = DbType.Double for FLOAT(126)-columns. If I build it myself all normal double values are accepted.</li> </ul> <p>app.config:</p> <pre><code>&lt;startup&gt;&lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;&lt;/startup&gt; &lt;system.data&gt; &lt;DbProviderFactories&gt; &lt;add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" /&gt; &lt;/DbProviderFactories&gt; &lt;/system.data&gt; </code></pre> <p>any ideas what is the reason and how i'm gonna make it work for all the 3 providers?</p> <p>Thanks &amp; Best Regards - Matti</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload