In this scenario, we will read a table from an Oracle database using a context parameter to refer to the table name.
Create a new Job and add the following components by typing their names in the design workspace or dropping them from the Palette: a tOracleInput component and a tLogRow component.
Connect tOracleInput to tLogRow using a Row > Main link.
Double-click tOracleInput to open its Basic Settings view in the Component tab.
Select a connection type from the Connection Type drop-down list. In this example, it is Oracle SID.
Select the version of the Oracle database to be used from the DB Version drop-down list. In this example, it is Oracle 12-7.
In the Host field, enter the Oracle database server's IP address. In this example, it is 192.168.31.32.
In the Database field, enter the database name. In this example, it is TALEND.
In the Oracle schema field, enter the Oracle schema name. In this example, it is TALEND.
In the Username and Password fields, enter the authentication details.
Click the [...] button next to Edit schema to open the schema editor.
Click the [+] button to add four columns: ID and AGE of the integer type, NAME and SEX of the string type.
Click OK to close the schema editor and accept the propagation prompted by the pop-up dialog box.
Put the cursor in the Table Name field and press F5 for context parameter setting. The dialog box [New Context Parameter] pops up.
For more information about context settings, see Talend Studio User Guide.
In the Name field, enter the context parameter name. In this example, it is TABLE.
In the Default value field, enter the name of the Oracle database table to be queried. In this example, it is PERSON.
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.
"SELECT "+context.TABLE+".\"ID\", "+context.TABLE+".NAME, "+context.TABLE+".SEX, "+context.TABLE+".AGE FROM "+context.TABLE
Double-click tLogRow to open its Basic settings view in the Component tab.
In the Mode area, select Table (print values in cells of a table) for a better display of the results.
Press Ctrl + S to save the Job.
Press F6 to run the Job.
As shown above, the data in the Oracle database table PERSON is displayed on the console.
For related scenarios, see: