How to declare Date Type Global Variable and pass to Child Job

Eight Stars

How to declare Date Type Global Variable and pass to Child Job

Hi All,

I want to create a Date type Global variable which I want to pass to a Child Job. I am able to pass String and Integer Type to Child One. But getting hard luck with Date type one's. Below is the code i am writing in my tjavarow. In the Child Job context variables passing this Global Variables value. and using those. Now in the Child Job toracleInput I have to use the 2 Date type Context where Global variable Value will be coming from Parent Job.

String fromdate_file_epsilon=input_row.START_DATE1;
globalMap.put("fromdate_file_epsilon", fromdate_file_epsilon);
String todate_file_epsilon = input_row.END_DATE1;
globalMap.put("todate_file_epsilon",todate_file_epsilon);
Date fromdate_epsilon = input_row.START_DATE;
globalMap.put("fromdate_epsilon", fromdate_epsilon);
Date todate_epsilon = input_row.END_DATE;
globalMap.put("todate_epsilon", todate_epsilon);
Integer load_key_epsilon = input_row.LOAD_KEY;
globalMap.put("load_key_epsilon", load_key_epsilon);
System.out.println(fromdate_epsilon);

 


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: How to declare Date Type Global Variable and pass to Child Job

HI,

I strongly recommend you to leave date context variables as string and to convert the values as Oracle datatype using the to_date function into the where clause like this:

...
AND TRUNC(ACTIVITY_DATE) >= TO_DATE('" + context.FROMDATE + "', 'yyyy_mm-dd')"
...

date format is given here as an example.


TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: How to declare Date Type Global Variable and pass to Child Job

HI,

I strongly recommend you to leave date context variables as string and to convert the values as Oracle datatype using the to_date function into the where clause like this:

...
AND TRUNC(ACTIVITY_DATE) >= TO_DATE('" + context.FROMDATE + "', 'yyyy_mm-dd')"
...

date format is given here as an example.


TRF
Eight Stars

Re: How to declare Date Type Global Variable and pass to Child Job

Hi @TRF,

So you are suggesting me to pass the date type Variable to the Child Job as String? I have already created that type variable to be used in Child for creating File Output delimited. So My Query will be like this Select Column Names from Table where 

TRUNC(ACTIVITY_DATE) between
TO_DATE('" + context.FROMDATE + "', 'MM/dd/yyyy') and
TO_DATE('" + context.TODATE + "', 'MM/dd/yyyy') where context.FROMDATE and context.TODATE will be String Type Context of my Child Job and will get value in String of Parent Job of Global Variable right?
Fifteen Stars TRF
Fifteen Stars

Re: How to declare Date Type Global Variable and pass to Child Job

Right

TRF
Eight Stars

Re: How to declare Date Type Global Variable and pass to Child Job

Hi @TRF,

 

Your suggestion worked like charm as always. marking this post as resolved. Thanks a Lottttttttttt Smiley Happy

Fifteen Stars TRF
Fifteen Stars

Re: How to declare Date Type Global Variable and pass to Child Job

You're welcome


TRF

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

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog