[resolved] Passing global var of date type through tFlowTolterate to SQL query?

One Star

[resolved] Passing global var of date type through tFlowTolterate to SQL query?

TOS 3.2.1, Java Project
I am having difficulty passing global var of date type to SQL query.
Here is sql and I how I thought it should work ...
"select sl_date, sl_store, sl_cat, sl_price
from sales2
where sl_date = '((java.util.Date)globalMap.get("dateKey"))'"
but ... I got errors
- The method ExecuteQuery(String) in the type Statement is not applicable for the for the arguments (String, String)
- Syntax Error on token "dateKey",, expected
This global variable is created by tFlowTolterate component, where I specified "dateKey" variable.
Can you pass date type through tFlowTolterate further on MysqlInput control?

Accepted Solutions
Community Manager

Re: [resolved] Passing global var of date type through tFlowTolterate to SQL query?

Hello guy
try
"select sl_date, sl_store, sl_cat, sl_price
from sales2
where sl_date = '"+((java.util.Date)globalMap.get("dateKey"))+"'"

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Passing global var of date type through tFlowTolterate to SQL query?

Hello guy
try
"select sl_date, sl_store, sl_cat, sl_price
from sales2
where sl_date = '"+((java.util.Date)globalMap.get("dateKey"))+"'"

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
One Star

Re: [resolved] Passing global var of date type through tFlowTolterate to SQL query?

Shong, thanks bro!!
I guess those + signs are concatenation signs? I don't know anything Java, looks like I'll have to invest into learning it.
Community Manager

Re: [resolved] Passing global var of date type through tFlowTolterate to SQL query?

Hello
I guess those + signs are concatenation signs?

yes!Smiley Wink
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download