Dynamic SQL generation failed. No key information found.
564999Mar 2 2007 — edited Mar 6 2007I'm using ODP with 9.2, Visual Studio 2003, and C#.
The following code generates the subject error message when the command builder tries to build the update command (insert and delete work fine...):
<pre>
protected virtual void OnUpdateAttributes(string eventTableName, DataTable table)
{
OracleDataAdapter da = null;
//Setup the Data Adapter
da = new OracleDataAdapter();
da.SelectCommand = ((OracleConnection)base.Connection).CreateCommand();
da.SelectCommand.CommandText = "SELECT * FROM " + eventTableName;
OracleCommandBuilder tempCommandBuilder = new OracleCommandBuilder(da);
da.InsertCommand = tempCommandBuilder.GetInsertCommand();
da.UpdateCommand = tempCommandBuilder.GetUpdateCommand();
da.DeleteCommand = ((OracleConnection)base.Connection).CreateCommand();
da.DeleteCommand.CommandText = "Delete from " + eventTableName + " where EVENT_ID = :1";
da.DeleteCommand.Parameters.Add("pEventId", OracleDbType.Int64);
da.DeleteCommand.Parameters["pEventId"].SourceColumn = "EVENT_ID";
da.DeleteCommand.Parameters["pEventId"].SourceVersion = DataRowVersion.Original;
da.Update(table);
}
</pre>
I have trace turned on, and as can be seen below, the ODP internal error code is -1702:
<pre>
TIME:2007/ 3/ 2- 9: 0:11:521 TID:122c (ENTRY) OracleCommandBuilder::GetUpdateCommand()
TIME:2007/ 3/ 2- 9: 0:11:521 TID:122c (ENTRY) OracleCommand::OracleCommand(1)
TIME:2007/ 3/ 2- 9: 0:11:521 TID:122c (EXIT) OracleCommand::OracleCommand(1)
TIME:2007/ 3/ 2- 9: 0:11:521 TID:122c (ENTRY) OpsGetPrimaryKey()
TIME:2007/ 3/ 2- 9: 0:12: 20 TID:122c (EXIT) OpsGetPrimaryKey(): RetCode=0 Line=1047
TIME:2007/ 3/ 2- 9: 0:12: 20 TID:122c (ERROR) ODP error code=-1702
TIME:2007/ 3/ 2- 9: 0:12: 36 TID:122c (ENTRY) OracleTransaction::Rollback(1)
</pre>
I also tried catching the exception that is raised using OracleException, but that fails in a curious way. It catches the exception, but the exception object that is returned is null, e.g. catch (OracleException ex) results in a null ex. Weird.
I can't find anything that tells me what -1702 means. Moreover, I have about 50 tables I'm accessing, and exactly 2 work. In other words, the command builder for the update command succeeds for two of them, and fails for the rest.
Can anyone point me to a location for ODP internal error codes? Or shed some light on this in some way?
Thanks!