DB2 Version 9.7 for Linux, UNIX, and Windows

DB2BulkCopyColumnMapping Class

Represents a column mapping 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.MarshalByRefObject
      IBM.Data.DB2.DB2BulkCopyColumnMapping

Syntax

[Visual Basic]
NotInheritable Public Class DB2BulkCopyColumnMapping
[C#]
public sealed class DB2BulkCopyColumnMapping
[C++]
public __gc __sealed class DB2BulkCopyColumnMapping
[JScript]
public final class DB2BulkCopyColumnMapping

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 DB2BulkCopyColumnMapping instances.

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

  DB2BulkCopyColumnMapping colMapDeptNum = 
  new DB2BulkCopyColumnMapping("DEPTNUMB", "DEPTNO");
  DB2BulkCopyColumnMapping colMapDeptNme = 
  new DB2BulkCopyColumnMapping("DEPTNAME", "DEPTNAME");
  DB2BulkCopyColumnMapping colMapDeptMgr = 
  new DB2BulkCopyColumnMapping("MANAGER", "ADMRDEPT");
  DB2BulkCopyColumnMapping colMapDeptLoc = 
  new DB2BulkCopyColumnMapping("LOCATION", "LOCATION");

  salesCopy.ColumnMappings.Add(colMapDeptNum);
  salesCopy.ColumnMappings.Add(colMapDeptNme);
  salesCopy.ColumnMappings.Add(colMapDeptMgr);
  salesCopy.ColumnMappings.Add(colMapDeptLoc);

  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