这是我正在执行的代码:
public static void Main(string[] args)
{
var connectionString = "Data Source=dbname;User Id=usrname;Password=pass;";
DataTable dt = new DataTable("BULK_INSERT_TEST");
dt.Columns.Add("N", typeof(double));
var row = dt.NewRow();
row["N"] = 1;
using (var connection = new OracleConnection(connectionString)){
connection.Open();
using(var bulkCopy = new OracleBulkCopy(connection, OracleBulkCopyOptions.UseInternalTransaction))
{
bulkCopy.DestinationTableName = dt.TableName;
bulkCopy.WriteToServer(dt);
}
}
using (var connection = new OracleConnection(connectionString)){
connection.Open();
var command = new OracleCommand("select count(*) from BULK_INSERT_TEST", connection);
var res = command.ExecuteScalar();
Console.WriteLine(res); // Here I'm getting 0
}
}
它用于OracleBulkCopy
向表中插入 1 个条目,然后计算表中的行数。为什么我得到0
行?这是表的结构:
-- Create table
create table BULK_INSERT_TEST
(
n NUMBER
)