OracleDataAdapter.Fill 在发出 DROP COLUMN 后给出错误

OracleDataAdapter.Fill gives error after issuing DROP COLUMN

我正在使用 ODP.NET (Oracle.ManagedDataAccess) 到 运行 对具有可插入数据库的 Oracle 12.2.0.1.0 数据库的查询。我在删除列后立即使用 OracleDataAdapter 时遇到错误。错误是 "ORA-01007: variable not in select list"。

问题只发生在我:

  1. 创建并使用 OracleDataAdapter (select *)
  2. 从 table
  3. 中删除一列
  4. 创建并使用另一个 OracleAdapter (select *)

它就像在缓存列(我正在使用 select * 作为命令)。有谁知道 ODP.net 驱动程序是否像这样进行某种内部缓存,我是否可以清除它?

DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();

using(var con = new OracleConnection(TestConnectionStrings[DatabaseType.Oracle]))
{
    con.Open();

    //OracleCommand drop = new OracleCommand("DROP TABLE RaceTable2", con);
    //drop.ExecuteNonQuery();

    OracleCommand create = new OracleCommand("CREATE TABLE RaceTable2 ( A int NOT NULL, B int NOT NULL, C int NOT NULL, D int NOT NULL, E int NOT NULL)",con);
    create.ExecuteNonQuery();

    var da = new OracleDataAdapter("select * from RaceTable2",con);
    da.Fill(dt1);

    OracleCommand dropCol = new OracleCommand("ALTER TABLE RaceTable2 DROP COLUMN E", con);
    dropCol.ExecuteNonQuery();

    var da2 = new OracleDataAdapter("select * from RaceTable2", con);
    da2.Fill(dt2); //crashes on this line
}

所以我认为这可能与Implicit Statement Caching有关。我在 ALTER 之后添加了对 PurgeStatementCache 的调用,这似乎修复了它:

con.PurgeStatementCache();

我只能假设这是在服务器端进行的,因为即使为第二个 select* 打开一个新连接也没有用。

要么是这样,要么是基于时间的事情,调用只会浪费服务器上的一些时间。