I want to set a context variable depending from a TalendDate routine in the "value as Table" tab which would allow me to select the day of yesterday : TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd"))

It does not work, I do not have any returns when I include in the selection as date('"+context.date+"').

Could you please tell me what I am missing ? I would be very grateful if you could help me with that.

有帮助吗?

解决方案 2

You should create a global variable, then in a tJava assign a value to it.

Or according to your current situation, in tJava paste the following:

context.date = TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd"));

Then you can use your variable. It won't be a java Date type, but a string.

其他提示

You can use the tContextLoad component to create key value pairs of contexts to be used in your job or child jobs.

In your case you would want to use a tFixedFlowInput component to specify what you wanted (or this could be any input really but this is just a way of hard coding it directly to the job without needing an external resource) and then link that to the tContextLoad component with a schema of key and value like so:

Defining context variables at run time

You'll want to use your original code snippet as the value in your tFixedFlowInput component:

tFixedFlowInput configuration

In the first screenshot above I've also added a tContextDump component and connected it to a tLogRow so you can see the available contexts to the job:

Output of tContextDump

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top