Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Write datetime end of a job in a variable

Hello,


Excuse me for my bad English, I'm French.
I will try to explain so say me if it's not clear for you.

I have a table with a field "date" and a line can be modified. When a line is modified, the field "date" is changed.

I have a job who is executed every day. This job gets data from my table. When the job is finished, I want to put the datetime of the end of my job in a variable. Before every launch of the job the file is deleted to create a new.

I want to use this variable in my request SQL.  

Thanks you very much.

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello,

I’ve tried to do things, but I don’t know if the method is right.
0683p000009M9Kq.png- I created a file manuallly "Date" where I have a line "Date;2020-11-12 12:45:30"
- I read this file with "tFileInputDelimited"
- I modified the schema of "tFileInputDelimited" to create two varaible "key" and "value"
- I created a context variable "Date" and in my request SQL I used "context.date" in my where clause.

It works but I don't know how to do after the "t_ESBConsumer_1". 
I want that when it is finished, I delete the file to create a new one with the same line but the value corresponds to the end date of execution of the job.

I know I must use the function "TalendDate. formatDate("dd/MM/YYYYM HH:mm:ss",TalendDate. getCurrentDate());" 



View solution in original post

5 Replies
Anonymous
Not applicable
Author

Hi,

 

   Are you trying to store the last run time of a job to a variable so that you can do delta data extraction operations? If that is the case, you can have a configuration or activity tracking table where you can store the last run time. Read the data from this table as the first step and assign to a context variable. Then use it for doing your business delta records processing. Once its completed, pick the last modified time of the latest record and store this value to the earlier context variable. In the next subjob, insert this value of context variable back to the configuration table to track the last processing time.

 

  If your requirement is different, please share your job screenshots along with detailed description so that we will have better idea.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

 

Anonymous
Not applicable
Author

Hello,

Thank you for your help.

I have this job :

- Read the last end time of the job in a file (the first time I launch the job, I don't have this file)
- Get the data from a table A where the "date field" is > end time of the job. So I must read the date of the file.
- Insert this data into a table B
- Delete the file and write the end time of the job in a file (with same name)

And so on and so forth

I don't want a table to put the end time of my job. I prefer a file but I don't know how to write into and read it to put into a variable to use it in my sql. The variable must be "global" because I want to use it in different jobs.

Anonymous
Not applicable
Author

I have this :

Job 1 :
tESBProviderRequest — tMap - tMySqlOutput (table « B »)

This is my first job. It's a webservice who inserts data in my table « B »

Job 2 :
tMysqlInput (table « A ») — tMap - tEsbConsumer

This is my second job. It's a job who gets the data from the table « A » and consumes the webservice of the job 1 to insert it in the table « B ». In the table « A », there is a field "date modification"

I want :

When the data are inserted into the table « B », I want to put the datetime end of the job into a file. When I get the data from the table « A » in my SQL request, I want only the data where the field "date modification" is higher than the date in the file.
Anonymous
Not applicable
Author

Hello,

Anyone have the solution ?

Thanks.
Anonymous
Not applicable
Author

Hello,

I’ve tried to do things, but I don’t know if the method is right.
0683p000009M9Kq.png- I created a file manuallly "Date" where I have a line "Date;2020-11-12 12:45:30"
- I read this file with "tFileInputDelimited"
- I modified the schema of "tFileInputDelimited" to create two varaible "key" and "value"
- I created a context variable "Date" and in my request SQL I used "context.date" in my where clause.

It works but I don't know how to do after the "t_ESBConsumer_1". 
I want that when it is finished, I delete the file to create a new one with the same line but the value corresponds to the end date of execution of the job.

I know I must use the function "TalendDate. formatDate("dd/MM/YYYYM HH:mm:ss",TalendDate. getCurrentDate());"