DB2DataWriter

We assume that you have already learned what is described in:

If you want to find the right Writer for your purposes, see Writers Comparison.

Short Summary

DB2DataWriter loads data into DB2 database.

Component Data output Input ports Output ports Transformation Transf. required Java CTL
DB2DataWriterdatabase0-10-1nononono

Abstract

DB2DataWriter loads data into database using DB2 database client. It can read data through the input port or from an input file. If the input port is not connected to any other component, data must be contained in an input file that should be specified in the component. If you connect some other component to the optional output port, it can serve to log the information about errors. DB2 database client must be installed and configured on localhost. Server and database must be cataloged as well.

Icon

Ports

Port typeNumberRequiredDescriptionMetadata
Input01)Records to be loaded into the databaseAny
Output0noFor information about incorrect recordsError Metadata for DB2DataWriter2)

Legend:

1): If no file containing data for loading (Loader input file) is specified, input port must be connected.

2): Error Metadata cannot use Autofilling Functions.

Table 46.1. Error Metadata for DB2DataWriter

Field numberField nameData typeDescription
0<any_name1>integerNumber of incorrect record (records are numbered starting from 1)
1<any_name2>integernumber of incorrect field (for delimited records), fields are numbered starting from 1 | offset of incorrect field (for fixed-length records)
2<any_name3>stringError message

DB2DataWriter Attributes

AttributeReqDescriptionPossible values
Basic
File metadata Metadata of external file. Must only be delimited. Each column except the last one is followed by an identical, one char delimiter. The last delimiter following the last column is \n. Delimiter must not be a part of any field value. 
DatabaseyesName of the database into which the records should be loaded. 
Database tableyesName of the database table into which the records should be loaded. 
User nameyesDatabase user. 
PasswordyesPassword for database user. 
Load mode Mode of the action performed when loading data. See Load mode for more information.insert (default) | replace | restart | terminate
Field mapping1)Sequence of individual mappings ($CloverField:=DBField) separated by semicolon, colon, or pipe. See Mapping of Clover Fields to DB Fields for more information. 
Clover fields1)Sequence of Clover fields separated by semicolon, colon, or pipe. See Mapping of Clover Fields to DB Fields for more information. 
DB fields1)Sequence of DB fields separated by semicolon, colon, or pipe. See Mapping of Clover Fields to DB Fields for more information. 
Advanced
Loader input file2)Name of input file to be loaded, including path. See Loader input file for more information. 
Parameters All parameters that can be used as parameters by load method. These values are contained in a sequence of pairs of the following form: key=value, or key only (if the key value is the boolean true) separated from each other by semicolon, colon, or pipe. If the value of any parameter contains the delimiter as its part, such value must be double quoted. 
Rejected records URL (on server) Name of the file, including path, on DB2 server where rejected records will be saved. Must be located in the directory owned by database user. 
Batch file URL URL of the file where the connect, load and disconnect commands for db2 load utility are stored. Normally the batch file is automatically generated, stored in current directory and deleted after the load finishes. If the Batch file URL is specified, component tries to use it as is (generates it only if it does not exist or if its length is 0) and does not delete it after the load finishes. (It is reasonable to use this attribute in connection with the Loader input file attribute, because batch file contains the name of temporary data file which is generated at random, if not provided explicitly). Path must not contain white spaces. 
DB2 command interpreter Interpreter that should execute script with DB2 commands (connect, load, disconnect). Its form must be the following: interpreterName [parameters] ${} [parameters]. This ${} expression must be replaced by the name of this script file. 
Use pipe transfer By default, data from input port is written to a temporary file and then it is read by the component. If set to true, on Unix data records received through the input port are sent to pipe instead of a temporary file.false (default) | true
Column delimiter The first one char field delimiter from File metadata or the metadata on the input edge (if File metadata is not specified). Character used as a delimiter for each column in data file. Delimiter must not be contained as a part of a field value. The same delimiter can be set by specifying the value of the coldel parameter in the Parameters attribute. If Column delimiter is set, coldel in Parameters is ignored. 
Number of skipped records Number of records to be skipped. By default, no records are skipped. This attribute is applied only if data is received through the input port. Otherwise, it is ignored.0 (default) | 1-N
Max number of records Maximum number of records to be loaded into database. The same can be set by specifying the value of the rowcount parameter in the Parameters attribute. If rowcount is set in Parameters, the Max number of records attribute is ignored.all (default) | 0-N
Max error count Maximum number of records after which the load stops. If some number is set explicitely and when it is reached, process can continue in RESTART mode. In REPLACE mode, process continues from the beginning. The same number can be specified with the help of warningcount in the Parameters attribute. If warningcount is specified, Max error count is ignored.all (default) | 0-N
Max warning count Maximum number of printed error messages and/or warnings.999 (default) | 0-N
Fail on warnings By default, the component fails on errors. Switching the attribute to true, you can make the component fail on warnings. Background: when an underlying bulk-loader utility finishes with a warning, it is just logged to the console. This behavior is sometimes undesirable as warnings from underlying bulk-loaders may seriously impact further processing. For example, 'Unable to extend table space' may result in not loading all data records to a database; hence not completing the expected task successfully. false (default) | true

Legend:

1) See Mapping of Clover Fields to DB Fields for more information about their relation.

2) If input port is not connected, Loader input file must be specified and contain data. See Loader input file for more information.

Advanced Description

Mapping of Clover Fields to DB Fields

Load mode

Loader input file

Loader input file is the name of input file with data to be loaded, including its path. Normally this file is a temporary storage for data to be passed to dbload utility unless named pipe is used instead. Remember that DB2 client must be installed and configured on localhost (see DB2 client setup overview). Server and database must be cataloged as well.