I am using OracleBlukCopy to dump a huge CSV file into the database table. Here is the code I am using. When I run this I am getting an error saying cannot insert NULL into TBL_COL1, but my CSV has values for TBL_COL1.
After research I came to conclusion that it is giving an error when TBL_COL1 has characters in it. Any idea why?
DataTable datatable = TranslateCSVFileToDataTable();
using (OracleConnection connectiontodb = new OracleConnection(databaseconnectionstring))
{
connectiontodb.Open();
using (OracleBulkCopy copytothetable = new OracleBulkCopy(connectiontodb))
{
copytothetable.ColumnMappings.Add("TBL_COL1", "TBL_COL1");
copytothetable.ColumnMappings.Add("TBL_COL2", "TBL_COL2");
copytothetable.ColumnMappings.Add("TBL_COL3", "TBL_COL3");
copytothetable.DestinationTableName = "DESTINATION_TABLE";
copytothetable.WriteToServer(datatable);
}
}
CREATE TABLE DESTINATION_TABLE
(
TBL_COL1 VARCHAR2(32) not null,
TBL_COL2 DATE not null,
TBL_COL3 DATE not null,
)
98987987987987987,6/23/2014,7/23/2014
98987987987987987,7/23/2014,8/21/2014
98987987987987987,8/21/2014,9/22/2014
98987987987987987,9/22/2014,10/21/2014
98987987987987987,10/21/2014,11/20/2014
98987987987987987,11/20/2014,12/22/2014
656666666666666ABC1234,1/8/2014,1/9/2014
656666666666666ABC1234,1/9/2014,2/9/2014
656666666666666ABC1234,2/9/2014,3/9/2014
656666666666666ABC1234,3/9/2014,4/7/2014
656666666666666ABC1234,4/7/2014,5/7/2014
656666666666666ABC1234,5/7/2014,6/8/2014
656666666666666ABC1234,6/8/2014,7/8/2014
656666666666666ABC1234,7/8/2014,8/7/2014
656666666666666ABC1234,8/7/2014,9/8/2014
656666666666666ABC1234,9/8/2014,10/7/2014
656666666666666ABC1234,10/7/2014,11/9/2014
656666666666666ABC1234,11/9/2014,12/7/2014
777777777777777XYZ1234,5/7/2014,6/8/2014
777777777777777XYZ1234,6/8/2014,7/8/2014
777777777777777XYZ1234,7/8/2014,8/7/2014
777777777777777XYZ1234,8/7/2014,9/8/2014
777777777777777XYZ1234,9/8/2014,10/7/2014
777777777777777XYZ1234,10/7/2014,11/9/2014
777777777777777XYZ1234,11/9/2014,12/7/2014