We assume that you have already learned what is described in:
If you want to find the right Joiner for your purposes, see Joiners Comparison.
DBJoin receives data through a single input port and joins it with data from a database table. These two data sources can potentially have different metadata structures.
Component | Same input metadata | Sorted inputs | Slave inputs | Outputs | Output for drivers without slave | Output for slaves without driver | Joining based on equality |
---|---|---|---|---|---|---|---|
DBJoin | no | no | 1 (virtual) | 1-2 | yes | no | yes |
DBJoin receives data through a single input port and joins it with data from a database table. These two data sources can potentially have different metadata structure. It is a general purpose joiner usable in most common situations. It does not require the input to be sorted and is very fast as data is processed in memory.
The data attached to the first input port is called the master, the second data source is called slave. Its data is considered as if it were incoming through the second (virtual) input port. Each master record is matched to the slave record on one or more fields known as a join key. The output is produced by applying a transformation that maps joined inputs to the output.
DBJoin receives data through a single input port and joins it with data from a database table. These two data sources can potentially have different metadata structure.
The joined data is then sent to the first output port. The second output port can optionally be used to capture unmatched master records.
Port type | Number | Required | Description | Metadata |
---|---|---|---|---|
Input | 0 | yes | Master input port | Any |
1 (virtual) | yes | Slave input port | Any | |
Output | 0 | yes | Output port for the joined data | Any |
1 | no | Optional output port for master data records without
slave matches. (Only if the Join type
attribute is set to Inner join .) This
applies only to LookupJoin and
DBJoin. | Input 0 |
Attribute | Req | Description | Possible values |
---|---|---|---|
Basic | |||
Join key | yes | Key according to which the incoming data flows are joined. See Join key. | |
Left outer join | If set to true , also driver records
without corresponding slave are parsed. Otherwise,
inner join is performed. | false (default) | true | |
DB connection | yes | ID of the DB connection to be used as the resource of slave records. | |
DB metadata | ID of DB metadata to be used. If not set, metadata is extracted from database using SQL query. | ||
Query URL | 3) | Name of external file, including path, defining SQL query. | |
SQL query | 3) | SQL query defined in the graph. | |
Transform | 1), 2) | Transformation in CTL or Java defined in the graph. | |
Transform URL | 1), 2) | External file defining the transformation in CTL or Java. | |
Transform class | 1), 2) | External transformation class. | |
Cache size | Maximum number of records with different key values that can be stored in memory. | 100 (default) | |
Advanced | |||
Transform source charset | Encoding of external file defining the transformation. | ISO-8859-1 (default) | |
Deprecated | |||
Error actions | Definition of the action that should be performed when the specified transformation returns some Error code. See Return Values of Transformations. | ||
Error log | URL of the file to which error messages for specified Error actions should be written. If not set, they are written to Console. |
Legend:
1) One of these transformation attributes should be set. Any of them must use a
common CTL template for Joiners or implement a
RecordTransform
interface.
See CTL Scripting Specifics or Java Interfaces for more information.
See also Defining Transformations for detailed information about transformations.
2) The unique exception is the case when none of these three attributes is specified, but the SQL query attribute defines what records will be read from DB table. Values of Join key contained in the input records serve to select the records from db table. These are unloaded and sent unchanged to the output port without any transformation.
3) One of these attributes must be specified. If both are defined, Query URL has the highest priority.
The Join key is a sequence of field names from master data source separated from each other by a semicolon, colon, or pipe. You can define the key in the Edit key wizard.
Order of these field names must correspond to the order of the key fields from database table (and their data types). The slave part of Join key must be defined in the SQL query attribute.
One of the query attributes must contain the expression of
the following form: ... where field_K=? and
field_L=?
.
Example 56.3. Join Key for DBJoin
$first_name;$last_name
This is the master part of fields that should serve to join master records with slave records.
SQL query must contain the expression that can look like this:
... where fname=? and lname=?
Corresponding fields will be compared and matching values will serve to join master and slave records.
When you define your join attributes you must specify a transformation that maps fields from input data sources to the output. This can be done using the Transformations tab of the Transform Editor. However, you may find that you are unable to specify more advanced transformations using this easist approach. This is when you need to use CTL scripting.
For detailed information about CloudConnect Transformation Language see Part XI, CTL - CloudConnect Transformation Language. (CTL is a full-fledged, yet simple language that allows you to perform almost any imaginable transformation.)
CTL scripting allows you to specify custom field mapping using the simple CTL scripting language.
All Joiners share the same transformation template which can be found in CTL Templates for Joiners.
If you define your transformation in Java, it must implement the following interface that is common for all Joiners: