Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Changing context variable values for the same job

Hi,
I have a set of jobs that uses a single context variable. This context variable is defined in the 'Contexts' in the Repository tree and is inturn used by every job.
This context variable takes in the values of 0 or 1. As of now I have set it to 1.
I want to run the job as a .sh file and pass 0 or 1 to the context variable. How can I accomplish this? My idea was to use the jobs to the work of both '1' and '0' without having to recreate the jobs separately.
Also, I want the jobs to run with context variable = 1 at a specified time and the jobs to run with context variable = 0 at Another specified time
Note : I am using TOS
Any thoughts on this would be greatly appreciated
Thanks
Rathi
Labels (2)
12 Replies
Anonymous
Not applicable
Author

You can pass values at runtime by modifying the launch script, for example: -
--context_param myString="modified value"
This is not the most elegant approach, depending on what your trying to achieve.
You can run your Jobs within different "contexts" and also take other approaches to 'externalise' your context values.
However, to answer your question, this is the solution.
Anonymous
Not applicable
Author

Thank you for the quick response.
I have complex stored procedures to which I have to pass these context variables. The procedures have been written to work for both 1 and 0. So I just write in talend "select * from myproc("+context.variable+")". Through this I can use a single job that uses a single procedure and hence, work for both 1 and 0. 
Will you please help me understand how do I  use different contexts for the select statement I have mentioned or maybe how to externalize it?
Thanks
Rathi
Anonymous
Not applicable
Author

It sounds like this may me the correct approach for what you're trying to achieve.
For more information on Context externalisation, I'd read about implicit loading and the tLoadContext component.
Anonymous
Not applicable
Author

Thank you.
As per my understanding, context externalization can be done when I run the job from talend, but, is it possible use it when I export the job and run it as a .sh file ?
 Also, my requirement is to also specify the time at which it should run daily. The job should run twice during the day with context.variable = 1 and run once in the night with context.variable = 0.
Any thoughts on this?
Thanks
Rathi
Anonymous
Not applicable
Author

That is not correct. You can externalise when you export/build your Job.
To run your Job at specified times, you need a Job Scheduler. If you're using Open Studio, you can use cron on Unix/Linux or Windows scheduler. You can pass the context value (on cron, at least) directly from the scheduler as the last parameter in your .sh fils is "$@"
Anonymous
Not applicable
Author

Hi,
I was trying to use tloadcontext in my requirement.
Like I said earlier, I have a set of jobs inked to each other. With tloadcontext I can pass the context value to the first job. How do I propagate the context value to the next set of jobs.
tloadcontext --> job1 --> job2 --> job3 -- etc
Note : job1, job2 etc are all individual jobs
Thanks
Rathi
Anonymous
Not applicable
Author

There's a checkbox on tRunJob that allows you to "transmit" context
Anonymous
Not applicable
Author

That's great tal00000. Thank you.
But I am not using trunjob, I have just linked all jobs sequentially under a single job. Can I get it to work here?
Thanks
Rathi
Anonymous
Not applicable
Author

Then you are using tRunJob.
If one Job calls another, then it is using the tRunJob component.