August 15, 2023

Scenario: Updating data using tMysqlOutput – Docs for ESB 6.x

Scenario: Updating data using tMysqlOutput

This Java scenario describes a two-component Job that updates data in a MySQL table
according to that in a delimited file.

  • Drop tFileInputDelimited and tMysqlOutput from the Palette onto the design workspace.

  • Connect the two components together using a Row
    Main
    link.

Use_Case_tMySQLOutput11.png
  • Double-click tFileInputDelimited to display
    its Basic settings view and define the
    component properties.

  • From the Property Type list, select Repository if you have already stored the metadata of
    the delimited file in the Metadata node in the
    Repository tree view. Otherwise, select
    Built-In to define manually the metadata of
    the delimited file.

    For more information about storing metadata, see
    Talend Studio

    User Guide.

Use_Case_tMySQLOutput12.png
  • In the File Name field, click the three-dot
    button and browse to the source delimited file that contains the modifications
    to propagate in the MySQL table.

    In this example, we use the customer_update file that
    holds four columns: id, CustomerName,
    CustomerAddress and idState. Some
    of the data in these four columns is different from that in the MySQL
    table.

Use_Case_tMysqlOutput16.png
  • Define the row and field separators used in the source file in the
    corresponding fields.

  • If needed, set Header, Footer and Limit.

    In this example, Header is set to 1 since the
    first row holds the names of columns, therefore it should be ignored. Also, the
    number of processed lines is limited to 2000.

  • Click
    the three-dot button next to Edit Schema to
    open a dialog box where you can describe the data structure of the source
    delimited file that you want to pass to the component that follows.

Use_Case_tMySQLOutput13.png
  • Select the Key check box(es) next to the
    column name(s) you want to define as key column(s).

Note:

It is necessary to define at least one column as a key column for the Job to be
executed correctly. Otherwise, the Job is automatically interrupted and an error
message displays on the console.

  • In the design workspace, double-click tMysqlOutput to open its Basic
    settings
    view where you can define its properties.

Use_Case_tMysqlOutput14.png
  • Click Sync columns to retrieve the schema of
    the preceding component. If needed, click the three-dot button next to Edit schema to open a dialog box where you can check
    the retrieved schema.

  • From the Property Type list, select Repository if you have already stored the connection
    metadata in the Metadata node in the Repository tree view. Otherwise, select Built-In to define manually the connection
    information.

    For more information about storing metadata, see
    Talend Studio

    User Guide.

  • Fill in the database connection information in the corresponding
    fields.

  • In the Table field, enter the name of the
    table to update.

  • From the Action on table list, select the
    operation you want to perform, Default in this
    example since the table already exists.

  • From the Action on data list, select the
    operation you want to perform on the data, Update in this example.

  • Save your Job and press F6 to execute it.

Use_Case_tMySQLOutput20.png

Using you DB browser, you can verify if the MySQL table, customers,
has been modified according to the delimited file.

In the above example, the database table has always the four columns
id, CustomerName,
CustomerAddress and idState, but certain
fields have been modified according to the data in the delimited file used.


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x