DB2 Version 9.7 for Linux, UNIX, and Windows

DB2BulkCopy.ColumnMappings Property

Mappings of columns from the data source table to columns in the destination table.

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

Syntax

[Visual Basic]
Public Property ColumnMappings As DB2BulkCopyColumnMappingCollection
[C#]
public DB2BulkCopyColumnMappingCollection ColumnMappings {get; set;}
[C++]
public: __property DB2BulkCopyColumnMappingCollection* get_ColumnMappings();
public: __property void set_ColumnMappings(DB2BulkCopyColumnMappingCollection*);
[JScript]
public function get ColumnMappings() : DB2BulkCopyColumnMappingCollection;
public function set ColumnMappings(DB2BulkCopyColumnMappingCollection);

Property value

A collection of column mappings. By default, this is an empty collection.

Remarks

The mappings defined in the DB2BulkCopyColumnMappingCollection instance are validated in the WriteToServer() call.

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");
  }
}

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