tDBInput
Executes a DB query with a strictly defined order which must correspond to the
schema definition. Then it passes on the field list to the next component via a Main row
link.
To use this component, relevant DBMSs’ ODBC drivers should be installed
and the corresponding ODBC connections should be configured via the database connection
configuration wizard.
tDBInput Standard properties
These properties are used to configure tDBInput running in the Standard Job framework.
The Standard
tDBInput component belongs to the Databases family.
The component in this framework is generally available.
Basic settings
Property type |
Either Built-in or |
|
Built-in: No property data stored |
|
Repository: Select the repository |
|
Click this icon to open the database connection configuration For more information about setting up and storing database |
Database |
Name of the data source defined via the database connection |
Username and |
DB user authentication data. To enter the password, click the […] button next to the |
Schema and Edit |
A schema is a row description. It defines the number of fields (columns) to This component offers the This dynamic schema |
|
Built-In: You create and store the |
|
Repository: You have already created |
Click Edit schema to make changes to the schema.
|
|
Table Name |
Name of the source table where changes made to data should be |
Query type |
Either Built-in or |
|
Built-in: Fill in manually the |
|
Repository: Select the relevant |
Query |
Enter your DB query paying particularly attention to properly |
Advanced settings
Additional JDBC parameters |
Specify additional connection properties for the database Note:
You can set the encoding parameters through this field. |
Trim all the String/Char columns |
Select this check box to remove leading and trailing whitespace |
Trim column |
Remove leading and trailing whitespace from defined |
tStatCatcher Statistics |
Select this check box to collect log data at the component |
Enable parallel execution |
Select this check box to perform high-speed data processing, by treating multiple data flows
simultaneously. Note that this feature depends on the database or the application ability to handle multiple inserts in parallel as well as the number of CPU affected. In the Number of parallel executions field, either:
Warning:
|
Global Variables
Global Variables |
NB_LINE: the number of rows processed. This is an After
QUERY: the query statement being processed. This is a Flow
ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
This component offers the flexibility of the DB query and covers |
Scenario 1: Displaying selected data from DB table
The following scenario creates a two-component Job, reading data from a
database using a DB query and outputting delimited data into the standard output
(console).
As a prerequisite of this Job, the MySQL ODBC
driver must have been installed and the corresponding ODBC connection must have been
configured.
Procedure
- Drop a tDBInput and tLogRow component from the Palette to the design workspace.
-
Connect the components using Row >
Main link. -
Double-click tDBInput to open its Basic settings view in the Component tab.
-
Fill in the database name, the username and password in the corresponding
fields. -
Click Edit Schema and create a 2-column
description including shop code and sales. - Enter the table name in the corresponding field.
-
Type in the query making sure it includes all columns in the same order as
defined in the Schema. In this case, as we’ll select all columns of the schema,
the asterisk symbol makes sense. - Click on the second component to define it.
- Enter the fields separator. In this case, a pipe separator.
-
Now go to the Run tab, and click on Run to execute the Job.
The DB is parsed and queried data is extracted from the specified table and
passed on to the job log console. You can view the output file straight on the
console.For an example of the use of
Dynamic Schemas in Input components, see
Scenario 5: Writing dynamic columns from a database to an output file.
Scenario 2: Using StoreSQLQuery variable
dynamically feed the SQL query set in your tDBInput
component.
Procedure
-
Use the same scenario as scenario 1 above and add a third component,
tJava. -
Connect tDBInput to tJava using a trigger connection of the OnComponentOk type. In this case, we want the tDBInput to run before the tJava component.
- Set both tDBInput and tLogRow component as in tDBInput scenario 1.
- Click anywhere on the design workspace to display the Contexts property panel.
-
Create a new parameter called explicitly StoreSQLQuery. Enter a default value of 1. This value of 1 means
the StoreSQLQuery is “true” for a use in the
QUERY global variable. -
Click on the tJava component to display the
Component view. Enter the
System.Out.println("")
command to display the query content,
press Ctrl+Space bar to access the variable
list and select the global variable QUERY. -
Go to your Run tab and execute the Job.
-
The query entered in the tDBInput component
shows at the end of the job results, on the log:For an example of the use of dynamic
schemas in Input components, see Scenario 5: Writing dynamic columns from a database to an output file.