问题
We migrated from oracle c12 to c19. And now we have simple test case that fails:
//arrange
string data = new string('x', 5000);
var connection = tm.GetConnection();
var createTableCmd = connection.CreateCommand(false);
createTableCmd.Text = "CREATE TABLE xx_temp (id NUMBER, text_long NCLOB, text_short NVARCHAR2(2000))";
createTableCmd.ExecuteNonQuery();
//act
var insertCmd = connection.CreateCommand(false);
insertCmd.Text = "INSERT INTO XX_TEMP (text_long) VALUES (@p1)";
var param = new OracleParameter("@p1", OracleDbType.NClob, data.Length, System.Data.ParameterDirection.Input);
param.Value = data;
insertCmd.Parameters.Add(param);
var insertResult = insertCmd.ExecuteNonQuery();
The last line fails with the error: ORA-64219: invalid LOB locator encountered
We're using Devart.Data.Oracle
component. And I have no idea what is wrong.
What is interesting is that when I'm trying to connect to DB from powershell using Oracle.ManagedDataAccess.dll
, I have no problems using similar code.
回答1:
Please upgrade to dotConnect for Oracle v9.11.980. The following code works with v9.11.980 and Oracle 19c:
//arrange
string data = new string('x', 5000);
var connection = new OracleConnection();
connection.ConnectionString = @"User Id=****;Password=****;Server=YOUR_HOST/YOUR_SID;Direct=true;";
connection.Open();
var createTableCmd = connection.CreateCommand();
//createTableCmd.CommandText = "DROP TABLE xx_temp";
//createTableCmd.ExecuteNonQuery();
createTableCmd.CommandText = "CREATE TABLE xx_temp (id NUMBER, text_long NCLOB, text_short NVARCHAR2(2000))";
createTableCmd.ExecuteNonQuery();
//act
var insertCmd = connection.CreateCommand();
insertCmd.CommandText = "INSERT INTO XX_TEMP (text_long) VALUES (:p1)";
var param = new OracleParameter("p1", OracleDbType.NClob, data.Length, System.Data.ParameterDirection.Input);
param.Value = data;
insertCmd.Parameters.Add(param);
var insertResult = insertCmd.ExecuteNonQuery();
来源:https://stackoverflow.com/questions/61338691/ora-64219-invalid-lob-locator-encountered