O'Reilly logo

Talend Open Studio Cookbook by Rick Barton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using context and globalMap variables in SQL queries

It is possible to use parameters passed or created in a job to drive the results of a SQL query. This short recipe shows how.

Getting ready

Open the job jo_cook_ch07_0020_contextInQuery, which is a copy of the job from the previous recipe.

How to do it…

The steps to be performed are as follows:

  1. Open the tMysqlInput component.
  2. Change the final line to HAVING SUM(o.`orderTotal`) > "+context.minOrderValue.
  3. Run the job and you will be prompted for a value.
  4. Enter 10 and click on Ok.
  5. You should see that the result set contains orders where the sum of the lines is > 10.

How it works…

The SQL statement used by tMysqlInput is held in a string, so can be manipulated just as any other string in Java. Thus, we can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required