Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First, I think you should report this to Oracle as a bug. The error happens even if the table is really small. It has nothing to do with indexes or primary keys, the error occurs even if the table has no index. If you set the value of ID to 0, the insert will run OK.</p> <p>I managed to create a workaround, although it is not a good one it may be good enough for your case.</p> <p>The workaround is to use the native Oracle client classes for the ODP.Net, so you would have to check if your app was configured for ODP or one of the others and choose your code accordingly.</p> <p>A "ODP Only" version of your function could look like this:</p> <pre><code> protected void CreateComponentODPOnly(Oracle.DataAccess.Client.OracleConnection cntn, string tableName) { int newId; System.Data.DataSet _dataSet = new DataSet(); Oracle.DataAccess.Client.OracleCommand selectCmd = new Oracle.DataAccess.Client.OracleCommand(); selectCmd.Connection = cntn; selectCmd.CommandText = string.Format( "SELECT * FROM {0} WHERE ID = (SELECT MAX(ID) FROM {0})", tableName); Oracle.DataAccess.Client.OracleDataAdapter dataAdapter = new Oracle.DataAccess.Client.OracleDataAdapter(); Oracle.DataAccess.Client.OracleCommandBuilder cmdBuilder = new Oracle.DataAccess.Client.OracleCommandBuilder(); dataAdapter.SelectCommand = selectCmd; cmdBuilder.DataAdapter = dataAdapter; 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"] = (Decimal)newId; _dataSet.Tables[tableName].Rows.Add(newRow); dataAdapter.InsertCommand = cmdBuilder.GetInsertCommand(); dataAdapter.Update(_dataSet.Tables[tableName]); } </code></pre>
 

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