How to pass a parmeter value into MySQL query within Talend

One Star

How to pass a parmeter value into MySQL query within Talend

I just started working with Talend and I have a basic question regarding passing parameters into a MySQL query within Open Studio. I have a basic ETL process that I wanted to parameterize the MONTH_ID and attempt to pass in a month id to process one month at a time.
For Example: (200801 would be the value I would want to parameterize.
SELECT Col1, col2, col3
FROM MySQL.Table
WHERE MONTH_ID = 200801

Questions:
1. From reading the forum it sounds like I need to use a context variable, but I am finding mix results on the syntax of passing it in the SQL. If it is a numeric do I just supply the context variable like - + context.month_id +
2. How do I supply the new value at run time. 200801, 200802, 200803,...201009?? Will I be prompted?

Thanks in advance - Mike D
One Star

Re: How to pass a parmeter value into MySQL query within Talend

The syntax in the query field can either be a literal, quoted string eg "SELECT ID, NAME FROM CUSTOMER" or any expression like "SELECT ID,NAME FROM CUSTOMER WHERE COUNTRY='" + context.CountryCode = "'"
In the context editor you can define default values and prompts for any context variable
T

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog