Oracle批量加载采用当前连接的方案

34gzjxbg  于 2023-10-16  发布在  Oracle
关注(0)|答案(1)|浏览(88)

Oracle Bulk Load采用当前连接的架构,是否有方法阻止它这样做?万一我不能创造这样一个同义词,我只是张贴。也就是说,当加载批量负载时,它不采取任何方案。

public class BulkLoader
    {
        public static void LoadBulkData(string connectionString, DataTable data, string tableName)
        {
            ConnectionProvider provider = new ConnectionProvider(connectionString);
            using (OracleConnection connection = provider.GetConnection())
            {
                OracleTransaction transaction = connection.BeginTransaction();
                try
                {
                    using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connection))
                    {
                        bulkCopy.DestinationTableName = tableName;
                        foreach (DataColumn column in data.Columns)
                        {
                            bulkCopy.ColumnMappings.Add(column.ColumnName, column.ColumnName);
                        }

                        bulkCopy.WriteToServer(data);
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception("Se produjo un error durante la carga masiva.", ex);
                }
            }
        }
    }

所指示的表是正确的表,但它始终采用当前连接的模式,例如Schema.Table,并且应该只是Table

b5lpy0ml

b5lpy0ml1#

checkout DestinationSchemaName以指定目标模式。
https://docs.oracle.com/en/database/oracle/oracle-database/21/odpnt/OracleBulkCopyMembers.html#GUID-80BDCCC2-09DA-4F47-8A9B-28969B078749

相关问题