Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I want to retrieve the data from mysql table based on date 2022-07-24 in dynamic way.
select * from table where loaddate= '2022-07-24'(need to update with dynamic)
what need to use here to go with dynamic way and I dont want to use context need to use in query only.
Thanks
Using context variable and update the value of context variable dynamically in the job. eg:
"select * from table where loaddate= '+context.loaddate+"'"
before the subjob starting with tMysqlInput, you can update the value of context variable dynamically on a tJava, eg:
tJava
|onsubjobok
tMysqlInput...
on tJava:
context.loadate=TalendDate.formatDate("yyyy-MM-dd",TalendDate.getCurrentDate());
//TalendDate.getCurrentDate() returns the current date, how/where does the loaddate come from in your case?
Regards
Shong
I'm having the same problem as the others.
Hi @Shicong Hong
if we want to do at DB component level what we can add like you have mentioned to have context parameter.
Any alternate way other than context param?
Thank you
are you able to do filter in DB itself using dynamic way.
what do you mean 'at DB component level? provide the value by user who run the job during the job execution? or load the value from somewhere?
Hi @Shicong Hong
I have tdbinput where I am using mysql conn and below query
select * from table where loaddate='<date>'
I am using hardcode value as of now but wanted to use the date in dynamic way but without using the context value.
@Vrushabh Malbari , Maybe I don't understand your requirement well, if you don't use context variable or global variable, how do you pass the value to the query at runtime? Can you explain what is the behavior you expect in dynamic way?