Configuring the components to use contexts
Procedure
-
Double-click tMysqlInput to open its
Basic Settings view in the Component tab.
-
From the Property Type list, select
Repository if you have already stored
the connection to database in the Metadata
node of the Repository tree view. The
property fields that follow are automatically filled in.
For more information about how to store a database connection, see Talend Studio User Guide.If you have not defined the database connection in the Repository, fill in the details manually after selecting Built-in from the Property Type list.
-
Set the Schema as Built-In and click Edit
schema to define the desired schema.
The schema editor opens:
-
Click the [+] button to add the rows
that you will use to define the schema, seven columns in this example:
id, first_name, last_name, city, state, date_of_birth and salary.
Under Column, click the fields to enter the corresponding column names.Click the fields under Type to define the type of data.Click OK to close the schema editor.
-
Put the cursor in the Table Name field
and press F5 for context parameter setting.
For more information about context settings, see Talend Studio User Guide.
- Keep the default setting in the Name field and type in the name of the database table in the Default value field, employees in this case.
-
Click Finish to validate the setting.
The context parameter context.TABLE automatically appears in the Table Name field.
-
In the Query type list, select Built-In. Then, click Guess
Query to get the query statement.
In this use case, we want to read the records with the salary above 8000. Therefore, we add a Where clause and the final query statement is as follows:
"SELECT "+context.TABLE+".`id`, "+context.TABLE+".`first_name`, "+context.TABLE+".`last_name`, "+context.TABLE+".`city`, "+context.TABLE+".`state`, "+context.TABLE+".`date_of_birth`, "+context.TABLE+".`salary` FROM "+context.TABLE+" WHERE "+context.TABLE+".`salary` > 8000"
-
Double-click tLogRow to set its Basic Settings in the Component tab.
- In the Mode area, select Table (print values in cells of a table) for a better display of the results.
- Save the Job.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!