DB2 Version 9.7 for Linux, UNIX, and Windows

DB2BulkCopyColumnMappingCollection Class

Represents a collection of column mappings from the data source table to the destination table.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Inheritance hierarchy

System.Object
   System.Collections.CollectionBase
      IBM.Data.DB2.DB2BulkCopyColumnMappingCollection

Syntax

[Visual Basic]
NotInheritable Public Class DB2BulkCopyColumnMappingCollection _
               Inherits System.Collections.CollectionBase
[C#]
public sealed class DB2BulkCopyColumnMappingCollection : 
  System.Collections.CollectionBase
[C++]
public ref class DB2BulkCopyColumnMappingCollection sealed : 
  public System.Collections.CollectionBase
[JScript]
public final class DB2BulkCopyColumnMappingCollection 
  extends System.Collections.CollectionBase

Remarks

If no column mappings are defined, columns are mapped based on their ordinal positions in their respective table schema. If the source and target columns are not compatible, an InvalidOperationException is thrown.

Example

[C#] The following example demonstrates a bulk copy of data from a DB2DataReader into the DEPARTMENT table. The column mappings between the source and target tables are defined by a DB2BulkCopyColumnMappingCollection instance.

[C#]
public static void copyIntoSales(DB2Connection conn, DB2DataReader reader)
{
  DB2BulkCopy salesCopy = new DB2BulkCopy(conn);
  salesCopy.DestinationTableName = "DEPARTMENT";

  DB2BulkCopyColumnMappingCollection colMapCollection;
  colMapCollection = new DB2BulkCopyColumnMappingCollection();

  salesCopy.ColumnMappings = colMapCollection;

  colMapCollection.Add("DEPTNUMB", "DEPTNO");
  colMapCollection.Add("DEPTNAME", "DEPTNAME");
  colMapCollection.Add("MANAGER", "ADMRDEPT");
  colMapCollection.Add("LOCATION", "LOCATION");

  try
  {
    salesCopy.WriteToServer(reader);
    salesCopy.Close();
  }
  catch (DB2Exception ex)
  {
    MessageBox.Show(ex.ToString(), "Exception");
  }
}

Thread safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.7
.NET Framework version
Supported in: 2.0, 3.0, 3.5 and 4.0
IBM Data Server Client
Supported in: IBM® DB2® Version 9 through Version 9.7