Context variable in SQL Querry ToracleInput

One Star

Context variable in SQL Querry ToracleInput

Hello,
I want to use parameter into a query for a ToracleInput component.

"SELECT....
FROM ....
WHERE DATECLOTURE <
(CASE WHEN " + context.Periode + "='MOIS_PASSE'
THEN LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-1))
ELSE SYSDATE
END)"
i have an error "non valid constant character"..
Thanks for your help..
Louis
One Star

Re: Context variable in SQL Querry ToracleInput

Hi Louis,
This is because the conevrted sql statement now contains your context.Periode as a constant. If you change your tOracleInput to the following it should work:
"SELECT....
FROM ....
WHERE DATECLOTURE <
(CASE WHEN '" + context.Periode + "'='MOIS_PASSE'
THEN LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE),-1))
ELSE SYSDATE
END)"

Regards,
Arno
One Star

Re: Context variable in SQL Querry ToracleInput

Thank you Arno !!! it's Ok !!
Regards,
Louis

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

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch