Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Soumya_M
Contributor
Contributor

Context variables

Hi all, I need your help regarding context variables in talend. So I have created this job to capture job details (like etl audit job)

0695b00000hs8kgAAA.png

My tDBRow has query:

"insert into public.jobs_exec(date_key,exec_key,job_id,job_status,start_time,end_time,src_count,tgt_count) 

select CURRENT_TIMESTAMP,0,job_id,'" + context.job_status + "',CURRENT_TIMESTAMP, null,0,0      

from public.jobs_property

where job_name ='" + context.job_name + "'"

this I have taken as sub-job in other job, where it is supposed to capture job execution details

0695b00000hs8lPAAQ.png

so, the audit job is supposed to capture the details of this job and update it in db accordingly. Though manually I'm able to execute the query (of tDBRow ) and populate jobs_exec table, but it's not happening via talend ? Where is it it that i'm missing ? any help would be appreciated

Labels (2)
6 Replies
Anonymous
Not applicable

Hi

"but it's not happenning via talend? "

What's the problem? Does the data are inserted correctly into DB when the query is executed on tDBRow?

one thing to note is that ​the value of context.job_name is the main job' name rather than child job's name in your example, you pass the main job's name to child job.

Regards

Shong

Soumya_M
Contributor
Contributor
Author

That's the issue - tDBRow query execution result data is not inserted into the db.

Yes, I do know that context.job_name is the main job name.

 

Anonymous
Not applicable

so, need to do more testing on your query, eg, use a tDBInput to execute this query

select CURRENT_TIMESTAMP,0,job_id,'" + context.job_status + "',CURRENT_TIMESTAMP, null,0,0      

from public.jobs_property

where job_name ='" + context.job_name + "'"

 

and output them on the console to check if it has the right result.

tDBInput--main--tLogRow

Soumya_M
Contributor
Contributor
Author

the output has no result, it returns 0 rows

Anonymous
Not applicable

this explains that's why no data are inserted into DB if you execute the query on tDBRow

"insert into public.jobs_exec(date_key,exec_key,job_id,job_status,start_time,end_time,src_count,tgt_count) 

select CURRENT_TIMESTAMP,0,job_id,'" + context.job_status + "',CURRENT_TIMESTAMP, null,0,0      

from public.jobs_property

where job_name ='" + context.job_name + "'"

 

Soumya_M
Contributor
Contributor
Author

I got the answer, thank you for the response