简体   繁体   English

OracleBulkCopy错误(表或视图不存在)

[英]OracleBulkCopy error (table or view does not exist)

I'm trying to copy datatable from sql server to oracle using OracleBulk Copy. 我正在尝试使用OracleBulk Copy将数据表从sql server复制到oracle。 However I'm getting the following error: 但是我收到以下错误:

ORA-00942: table or view does not exist ORA-00942:表或视图不存在

For the line orca_bulk_copy.WriteToServer(dt); 对于orca_bulk_copy.WriteToServer(dt); .

The code is as follows: 代码如下:

string sqlstring = "select POSITION_ID, POSITION_DESC  from T_CD_POSITION";
SqlDataAdapter o_SQLDataAdaptor = new SqlDataAdapter(sqlstring, sqlconn);
DataTable dt = new DataTable();
o_SQLDataAdaptor.Fill(dt);

//SqlCommand scmd = new SqlCommand(sqlstring, sqlconn);
//SqlDataReader reader = scmd.ExecuteReader();

foreach (DataRow row in dt.Rows)
{
    OracleConnection oraconn = new OracleConnection(oradb);
    oraconn.Open();
    Console.WriteLine("orca conn established....");


    OracleBulkCopy orca_bulk_copy = new OracleBulkCopy(oraconn);

    orca_bulk_copy.DestinationTableName = "UHAMPTST.t_test_postion";
    orca_bulk_copy.BatchSize = 5000;
    orca_bulk_copy.BulkCopyTimeout = 10000;
    Console.WriteLine("hh");
    orca_bulk_copy.ColumnMappings.Add("position_id", "position_id");

    orca_bulk_copy.ColumnMappings.Add("position_desc", "position_desc");
    orca_bulk_copy.WriteToServer(dt); // <----- ORA-00942 error occurs here!!
    Console.WriteLine("hhdd");
    orca_bulk_copy.Close();
    orca_bulk_copy.Dispose();

I did try to find why this error is coming but did not get enough info on it. 我确实试图找到为什么会出现此错误,但没有得到足够的信息。

ORA-00942 - Table does not exists error , one of the main error, any novice SQL developer faces. ORA-00942 - Table does not exists error ,这是任何新手SQL开发人员都会遇到的主要错误之一。 Please check the below. 请检查以下内容。

1) When you don't refer a table with a SCHEMA name, check whether a PUBLIC SYNONYM exists for it. 1)当您不使用SCHEMA名称引用表时,请检查是否存在PUBLIC SYNONYM If it doesn't or you cannot have a public synonym, either you have to explicitly specify the schema name as a prefix to the table, else the USER_ID you used to connect to the database has default access to that schema. 如果没有,或者您不能使用公共同义词,则必须显式地指定模式名称作为表的前缀,否则用于连接数据库的USER_ID对该模式具有默认访问权限。

2) Check whether, you have SELECT privileges from the table you try to select and INSERT/UPDATE privilege to the table you try to copy to. 2)检查您是否对尝试选择的表具有SELECT特权,对要复制到的表具有INSERT/UPDATE特权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM