OracleBulkCopyOptions Enumeration

The OracleBulkCopyOptions enumeration specifies the values that can be combined with an instance of the OracleBulkCopy class and used as options to determine its behavior and the behavior of the WriteToServer methods for that instance.

Table 17-17 lists all the OracleBulkCopyOptions enumeration values with a description of each enumerated value.

Table 17-17 OracleBulkCopyOptions Enumeration Members

Member Name Description

Default

Indicates that the default value for all options are to be used

NotifyAllRowsProcessed

Indicates when bulk copy has processed all the rows by sending a notification. This member can be used in conjunction with OracleBulkCopy.NotifyAfter or by itself. NotifyAfter sends notifications after a specific number of rows have been bulk copied. It only sends an alert when the entire bulk copy operation is completed if the NotifyAfter value is a multiple of the total rows copied.

For example, let's say you set NotifyAfter=5 without enabling NotifyAllRowsProcessed. When you bulk copy 15 rows, you will receive three alerts: once after 5 rows, once after 10, and once after 15. If you bulk 12 rows instead, then you would receive only two alerts: once after 5 rows and once after 10 rows. If you had also enabled NotifyAllRowsProcessed in both scenarios, then you would receive three alerts in both instances and always after the bulk copy operation completes processing the 15 rows.

NotifyAllRowsProcessed will send a notification when all the rows are processed regardless of NotifyAfter's value.

By design, NotifyAfter is intended to measure bulk copy progress. NotifyAllRowsProcessed is intended to indicate when bulk copy has processed all the rows.

This member is supported with managed ODP.NET and ODP.NET Core only starting with versions 23.5, 21.15, and 19.24.

UseInternalTransaction

Indicates that each batch of the bulk copy operation occurs within a transaction. If the connection used to perform the bulk copy operation is already part of a transaction, an InvalidOperationException exception is raised.

If this member is not specified, BatchSize number of rows are sent to the database, without any transaction-related activity.

Note:

All bulk copy operations are agnostic of any local or distributed transaction created by the application.

Requirements

Provider ODP.NET, Unmanaged Driver ODP.NET, Managed Driver ODP.NET Core

Assembly

Oracle.DataAccess.dll

Oracle.ManagedDataAccess.dll

Oracle.ManagedDataAccess.dll

Namespace

Oracle.DataAccess.Client

Oracle.ManagedDataAccess.Client

Oracle.ManagedDataAccess.Client

.NET Framework

See System Requirements

See System Requirements

-

.NET (Core)

-

-

See System Requirements

Sample Code: NotifyAllRowsProcessed

// Set up the bulk copy object so that it will notify the app when all rows have been copied.
using (OracleBulkCopy bulkCopy = new OracleBulkCopy(destinationConnection, OracleBulkCopyOption.NotifyAllRowsProcessed))
{
  bulkCopy.DestinationTableName = "BLOGS";
 
  try
  {
    // Write rows from the source to the destination.
    bulkCopy.NotifyAfter = 5;
    bulkCopy.OracleRowsCopied += new OracleRowsCopiedEventHandler(OnSqlRowsCopied);
    bulkCopy.WriteToServer(reader);
  }
  catch (Exception ex)
  {
    Console.WriteLine(ex.Message);
  }
  finally
  {
    // Close the OracleDataReader. The OracleBulkCopy object is automatically closed at the end of the using block.
    reader.Close();
  }
}