Skip to main content Skip to complementary content

Migrating from DatabaseSelect to a single tDBInput

Update your Job and map to replace the deprecated DatabaseSelect function with a tDBInput component.

Before you begin

  • You have a Job containing a tHMap that uses a DatabaseSelect function.
  • You have created a connection to your database in Talend Studio. For more information, see Setting up a database connection. Make sure that the schema is identical to the structure used in your map.

About this task

In this example, you have a simple Job with a tHMap that selects data from a database containing employee information and maps it to an XML structure, and a tFileOutputRaw that writes the result to an XML file. The Job looks like this:
The map used in the tHMap looks like this:

The goal of this example is to remove the deprecated DatabaseSelect function and keep the same behavior for the Job.

Procedure

  1. Drag and drop your input database table from Metadata > Db Connections in your Job, before the tHMap.
  2. Select tDBInput when prompted, then click OK.
  3. Link the tDBInput to your tHMap using a Row > Main connection.
  4. Double-click the tDBInput and update the query to match the filters used in the DatabaseSelect function.
    In this example, you want to select records where the value of EMPLOYEE_ID is greater than 200. The full query looks like this:
    "SELECT 
      `employees`.`EMPLOYEE_ID`, 
      `employees`.`FIRST_NAME`, 
      `employees`.`LAST_NAME`, 
      `employees`.`EMAIL`, 
      `employees`.`PHONE_NUMBER`, 
      `employees`.`HIRE_DATE`, 
      `employees`.`JOB_ID`, 
      `employees`.`SALARY`, 
      `employees`.`COMMISSION_PCT`, 
      `employees`.`MANAGER_ID`, 
      `employees`.`DEPARTMENT_ID`
    FROM `employees`
    WHERE `EMPLOYEE_ID` > 200"
  5. In the Mapping perspective, expand the Representations folder under the database table structure used as input in your map.
    • If there is a Map representation, you can go to the next step.
    • If there is no Map representation, right-click Representations and click New Map.
  6. Open the map used in your Job and click Database on the Input side, then select Map and click OK to update the representation.
  7. Remove the DatabaseSelect function in the input structure.

    It can be either on the root element or on the Row loop, in the IO/Database tab.

  8. Save your map and your Job.

Results

Your Job is now using the tDBInput component instead of the deprecated DatabaseSelect function. You can run the Job and you should get the same result.
Information noteTip: You may need to close and reopen your Job to remove the error icon on the tHMap.

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!