DBOutputTable

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

DBOutputTable loads data into database using JDBC driver.

Component Data output Input ports Output ports Transformation Transf. required Java CTL
DBOutputTabledatabase10-2
no
no
no
no

Abstract

DBOutputTable loads data into database using JDBC driver. It can also send out rejected records and generate autogenerated columns for some of the available databases.

Icon

Ports

Port typeNumberRequiredDescriptionMetadata
Input0
yes
Records to be loaded into the databaseAny
Output0
no
For rejected recordsBased on Input 01)
1
no
For returned valuesAny2)

Legend:

1): Metadata on output port 0 may contain any number of fields from input (same names and types) along with up to two additional fields for error information. Input metadata are mapped automatically according to their name(s) and type(s). The two error fields may have any names and must be set to the following Autofilling Functions: ErrCode and ErrText.

2): Metadata on output port 1 must include at least the fields returned by the returning statement specified in the query (for example, returning $outField1:=$inFieldA,$outField2:=update_count,$outField3:=$inFieldB). Remember that fields are not mapped by names automatically. A mapping must always be specified in the returning statement. Number of returned records is equal to the the number of incoming records.

DBOutputTable Attributes

AttributeReqDescriptionPossible values
Basic
DB connection
ID of the DB connection to be used. 
Query URL[ 1)]Name of external file, including path, defining SQL query. See Query or DB Table is Defined for more information. 
SQL query[ 1)]SQL query defined in the graph. See Query or DB Table is Defined for more information. See also SQL Query Editor. 
DB table[ 1)]Name of DB table. See Query or DB Table is Defined for more information. 
Field mapping[ 2)]Sequence of individual mappings ($CloverField:=DBField) separated by semicolon, colon, or pipe. See Mapping of Clover Fields to DB Fields for more information. 
Clover fields[ 2)]Sequence of Clover fields separated by semicolon, colon, or pipe. See Mapping of Clover Fields to DB Fields for more information. 
DB fields[ 2)]Sequence of DB fields separated by semicolon, colon, or pipe. See Mapping of Clover Fields to DB Fields for more information. 
Query source charset Encoding of external file defining SQL query.ISO-8859-1 (default) | <other encodings>
Batch mode By default, batch mode is not used. If set to true, batch mode is turned on. Supported by some databases only. See Batch Mode and Batch Size for more information.false (default) | true
Advanced
Batch size Number of records that can be sent to database in one batch update. See Batch Mode and Batch Size for more information.25 (default) | 1-N
Commit Defines after how many records (without an error) commit is performed. If set to MAX_INT, commit is never performed by the component, i.e., not untill the connection is closed during graph freeing. This attribute is ignored if Atomic SQL query is defined.100 (default) | 1-MAX_INT
Max error count Maximum number of allowed records. When this number is exceeded, graph fails. By default, no error is allowed. If set to -1, all errors are allowed. See Errors for more information.0 (default) | 1-N | -1
Action on error By default, when the number of errors exceeds Max error count, correct records are commited into database. If set to ROLLBACK, no commit of the current batch is performed. See Errors for more information.COMMIT (default) | ROLLBACK
Atomic SQL query Sets atomicity of executing SQL queries. If set to true, all SQL queries for one record are executed as atomic operation, but the value of the Commit attribute is ignored and commit is performed after each record. See Atomic SQL Query for more information.false (default) | true

[ 1)] One of these attributes must be specified. If more are defined, Query URL has the highest priority and DB table the lowest one. See Query or DB Table is Defined for more information.

[ 2)] See Mapping of Clover Fields to DB Fields for more information about their relation.

Advanced Description

Query or DB Table is Defined

Dollar Sign in DB Table Name

Mapping of Clover Fields to DB Fields

Batch Mode and Batch Size

  1. Batch Mode

    Batch mode speeds up loading of data into database.

  2. Batch Size

    Remember that some databases return as rejected more records than would correspond to their real number. These databases return even those records which have been loaded into database successfully and send them out through the output port 0 (if connected).

Errors

  1. Max error count

    Specifies number of errors that are still allowed, but after which graph execution stops. After that, defined Action on Error is performed.

  2. Action on Error

    COMMIT

    By default, when maximum number of errors is exceeded, commit is performed for correct records only in some databases. In others, rollback is performed instead. Then, graph stops.

    ROLLBACK

    On the other hand, if maximum number of errors is exceeded, rollback is performed in all databases, however, only for the last, non-commited records. Then, graph stops. All that has been comitted, cannot be rolled back anymore.

Atomic SQL Query

[Important]Important

Remember also, when connecting to MS SQL Server, it is convenient to use jTDS http://jtds.sourceforge.net driver. It is an open source 100% pure Java JDBC driver for Microsoft SQL Server and Sybase. It is faster than Microsoft's driver.

SQL Query Editor

For defining the SQL query attribute, SQL query editor can be used.

The editor opens after clicking the SQL query attribute row:

On the left side, there is the Database schema pane containing information about schemas, tables, columns, and data types of these columns.

Displayed schemas, tables, and columns can be filtered using the values in the ALL combo, the Filter in view textarea, the Filter, and Reset buttons, etc.

You can select any columns by expanding schemas, tables and clicking Ctrl+Click on desired columns.

Adjacent columns can also be selected by clicking Shift+Click on the first and the list item.

Select one of the following statements from the combo: insert, update, delete.

Then you need to click Generate after which a query will appear in the Query pane.

Generated Query with Question Marks

Figure 46.1. Generated Query with Question Marks


The query may contain question marks if any db columns differ from input metadata fields. Input metadata are visible in the Input metadata pane on the right side.

Drag and drop the fields from the Input metadata pane to the corresponding places in the Query pane and manually remove the "$?" characters. See following figure:

Generated Query with Input Fields

Figure 46.2. Generated Query with Input Fields


If there is an edge connected to the second output port, autogenerated columns and returned fields can be returned.

Generated Query with Returned Fields

Figure 46.3. Generated Query with Returned Fields


Two buttons allow you to validate the query (Validate) or view data in the table (View).