One Star

[resolved] Variable increment

hi,
i want to create a new column in my database with the type (integer).
For this i want to create a variable which increment of 1 everytime my job run.
Example :
1- First execution : the field takes the value 0
2-Second executon : the field takes the value 1
.
.
12-// //  : the field takes the value 11
any idea?
thanks
1 ACCEPTED SOLUTION

Accepted Solutions

Re: [resolved] Variable increment

Your job should be something like this:  Take Row count from your desired DB if its is zero give the JobCountRun Value as zero esle fetch the last saved jobCountRun Value and add by 1 and fed it to a context value, OnSubJobOk fetch the context value into DB as well as into a file from where you could fetch the JobCountRun which should be the JobCountRun value. In this way u can create and save a JobCountRun value into your DB whenever you Run your job multiple times.
4 REPLIES
One Star

Re: [resolved] Variable increment

after execution write current value to file.
on next execution read this value from file and increment it.(then write to file)
or when you execute your job, read max value from database(if not found, write 0), increment it and write to database
One Star

Re: [resolved] Variable increment

thx jetab , i understund your idea but how  to do it really in talend ? i'm really new using talend ...

Re: [resolved] Variable increment

Your job should be something like this:  Take Row count from your desired DB if its is zero give the JobCountRun Value as zero esle fetch the last saved jobCountRun Value and add by 1 and fed it to a context value, OnSubJobOk fetch the context value into DB as well as into a file from where you could fetch the JobCountRun which should be the JobCountRun value. In this way u can create and save a JobCountRun value into your DB whenever you Run your job multiple times.
One Star

Re: [resolved] Variable increment

thx for your reply . It works Smiley Very Happy