Context Variable As Source SQL filter

One Star

Context Variable As Source SQL filter

Hi,
I have a context variable PERIOD_YEAR and when I am using this variable in my source input SQL as below.
"SELECT C1,C2 FROM <ABC> WHERE PERIOD_YEAR = '"+context.PERIOD_YEAR"'"
when I am executing my ETL job, 'tOracleInput' object is throwing error as below 
ERROR:
'java.sql.SQLSyntaxErrorExecution: ORA-01722: invalid number'
Please provide your input to resolve the issue.
Thanks
Saket Krishna 

Ten Stars

Re: Context Variable As Source SQL filter

You need to remove the single quotes from around the value held by the context variable. So instead of this....
"SELECT C1,C2 FROM <ABC> WHERE PERIOD_YEAR = '"+context.PERIOD_YEAR"'"
....try this....
"SELECT C1,C2 FROM <ABC> WHERE PERIOD_YEAR = "+context.PERIOD_YEAR

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