Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

OracleBulkCopy.WriteToServer crashes when storing floating point numbers having more than 5 digits to FLOAT(53) fields

Artur ZasOct 25 2024

Hi,

OracleBulkCopy throws ORA-16550: truncated result https://docs.oracle.com/error-help/db/ora-16550/;
Stack trace:
at Oracle.ManagedDataAccess.Client.OracleBulkCopy.WriteDataSourceToServer(IBulkCopyDataSource dataSource)
at Oracle.ManagedDataAccess.Client.OracleBulkCopy.WriteToServer(DataTable table, DataRowState rowState)
at Oracle.ManagedDataAccess.Client.OracleBulkCopy.WriteToServer(DataTable table)

It does not matter if I use float, double, or decimal. The maximum digits that can be handled is 5:
(1.2345, 12.345, 123.45, 1234.5, etc.)

What can I do to bulk copy data to a database table with FLOAT(53) columns?

This code can be used to reproduce the issue:

using var connection = new OracleConnection("connection_string");
await connection.OpenAsync();

using OracleBulkCopy bulk = new(connection);

var dataTable = CreateTestDataTable();

bulk.BatchSize = 1000;
bulk.DestinationTableName = dataTable.TableName;

bulk.WriteToServer(dataTable);

await connection.CloseAsync();

public DataTable CreateTestDataTable()
{
DataTable dataTable = new("TestTable");
dataTable.Columns.Add(new DataColumn("MyValue", typeof(decimal)) { AllowDBNull = true });

DataRow row = dataTable.NewRow();
row["MyValue"] = 123.456;
dataTable.Rows.Add(row);

return dataTable;
}

Comments
Post Details
Added on Oct 25 2024
2 comments
63 views