- 3,715,654 Users
- 2,242,820 Discussions
- 7,845,479 Comments
Forum Stats
Discussions
Categories
- 17 Data
- 362.2K Big Data Appliance
- 7 Data Science
- 1.6K Databases
- 467 General Database Discussions
- 3.7K Java and JavaScript in the Database
- 22 Multilingual Engine
- 487 MySQL Community Space
- 3 NoSQL Database
- 7.6K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 416 SQLcl
- 42 SQL Developer Data Modeler
- 184.8K SQL & PL/SQL
- 21K SQL Developer
- 1.9K Development
- 3 Developer Projects
- 32 Programming Languages
- 135.1K Development Tools
- 8 DevOps
- 3K QA/Testing
- 247 Java
- 5 Java Learning Subscription
- 10 Database Connectivity
- 66 Java Community Process
- 1 Java 25
- 9 Java APIs
- 141.1K Java Development Tools
- 6 Java EE (Java Enterprise Edition)
- 153K Java Essentials
- 135 Java 8 Questions
- 86.2K Java Programming
- 270 Java Lambda MOOC
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 10 Java SE
- 13.8K Java Security
- 3 Java User Groups
- 22 JavaScript - Nashorn
- 18 Programs
- 125 LiveLabs
- 30 Workshops
- 9 Software
- 3 Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 3 Deutsche Oracle Community
- 10 Español
- 1.9K Japanese
- 2 Portuguese
ODP.NET 18.3 Bulkinsert with Nullable Types

I'm trying to get bulkinsert working in a .NET application.
I have a lot of string columns, a few int columns that al seem to work when my data POCO properties are of string or int.
The bulk insert fails to work when I try to insert a Nullable int (int?) as source! Which I didn't expect as the column in the table is nullable, and should be able to handle null.
Mind you, although the POCO property was int?, it had values for all rows the array I extracted from it. So it couldn't be a <null> problem.
The exception 'System.ArgumentException' (Value does not fall within the expected range) is thrown when I try to add the array to the Parameter property of the command. (So we don't even get to the database).
I'm using ODP.NET 18.3 as dataprovider. The application is written in C# 3.5.
So I have the following questions:
1) Can I use a Nullable type (int?, datetime?) in ODP.NET BulkInsert?
2) If the answer to the previous anwer is a yes, what should I take in consideration? What am I missing?
POCO
public class MyPoco
{
public int? MyInt { get; set; }
}
The code that extracts the array of values.
// Get the list of values (as object)
var valueObjectList = dataEntityList
.Select(item => propInfo.GetValue(item))
.ToList();
var parameter = command.CreateParameter();
parameter.Direction = ParameterDirection.Input;
parameter.IsNullable = true;
parameter.ParameterName = ":" + propInfo.Name;
dynamic result = null;
if (propertyType == typeof(int?))
{
result = ConvertToTypedList<int?>(valueObjectList);
parameter.Value = result; <----- this gives an ArgumentException
// More code that is unimportant.
'result' had values in it!
Regards
Marc
Answers
-
When inserting with Bulk Copy, NOT NULL is automatically enabled by default. You will find the full list of restrictions to use ODP.NET Bulk Copy here: https://docs.oracle.com/en/database/oracle/oracle-data-access-components/18.3/odpnt/featBulkCopy.html#GUID-91569C5F-52C3-4F95-8040-432A8AA8D0F8
-
I'm not talking about a bulkcopy from one DB to another DB, i'm talking about a bulkinsert, which is implemented bij the ODP.NET managed driver. I can bulkinsert with .NET types as strings and int, but not with an nullable int.
I don't see how this answer has anything to do with the question i asked.
-
It's not clear what feature you mean by "BulkInsert". There's a number of ways to use ODP.NET to insert bulk data into the DB.
-
If we are using ArrayBinding to bulkinsert data into Oracle tables, how do we insert null values for decimal columns?