Rounding off numeric data while using SqlBulkCopy in C#

c# oracle11g sqlbulkcopy sql-server

Question

I useSqlBulkCopy to import data into MS SQL Server 2012 from an Oracle 11g source. yet one of theNUMERIC values like 263.9(32 times) and 53682.0(35 times) are found in Oracle columns. Currently, the target column in SQL Server is aFLOAT I am now receiving the following Exception for my datatype:

Arithmetic operation resulted in an overflow.

Here is a snippet of my code:

using (SqlConnection conn = new SqlConnection(destConnString))
        {
            conn.Open();
            try
            {
                using (OracleConnection connection = new OracleConnection(srcConnString))
                {
                    using (OracleCommand command = new OracleCommand(selectQuery, connection))
                    {
                        connection.Open();
                        using (OracleDataReader reader = command.ExecuteReader(CommandBehavior.Default))
                        {
                            using (SqlBulkCopy bulkCopy = new SqlBulkCopy(conn, SqlBulkCopyOptions.KeepIdentity, trans))
                            {
                                bulkCopy.DestinationTableName = tableName;
                                bulkCopy.BulkCopyTimeout = 0;
                                bulkCopy.WriteToServer(reader);
                            }
                        }
                    }
                }
                trans.Commit();
            }
            ....

I'm attempting to round off this data, but I'm having no luck, and I also can't make any changes to the Oracle database.

1
3
2/20/2013 1:46:10 PM

Accepted Answer

Is it not possible to just alter your Oracle SELECT query, maybe by truncating the problematic numeric value?

2
2/20/2013 1:08:01 PM


Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow