Page 1 of 2

Batch ID in Datastage

Posted: Mon Dec 04, 2017 12:42 pm
by Awais Dildar
Hi All,

I have a requirement in designing a parallel job, at each Job run I have to store the Batch ID of the running job in the target table along with records insertion date. I tried to search a lot about getting the Batch ID of a job but found no appropriate solution. Can you please guide me how to get the Batch ID of each Job?
Looking forward for a positive response, thanks in advance.

Regards

Awais Dildar

Posted: Mon Dec 04, 2017 1:30 pm
by PaulVL
well... have you tried the "whoami" command? You could trap that and set an environment variable in your BEFORE JOB subroutine, or an external source stage.

Posted: Mon Dec 04, 2017 8:57 pm
by ray.wurlod
Welcome aboard.

DataStage does not innately generate Batch ID. You have to specify how this is to be generated.

It follows that you can do whatever you like with this generated/retrieved value.

Posted: Mon Dec 04, 2017 11:53 pm
by Awais Dildar
Paul,

Can you please explain briefly how to use "whoami" command to get batch id?

Posted: Tue Dec 05, 2017 12:01 am
by Awais Dildar
Ray,

Is there any mechanism to implicitly generate this batch ID within a job?

Posted: Tue Dec 05, 2017 8:19 am
by qt_ky
I do not think DataStage has a feature called "Batch ID."

Is "Batch ID" some sort of custom column or parameter in your environment?

Have you tried using a parameter?

Posted: Tue Dec 05, 2017 8:25 am
by sriven786
If you are looking for Id generation, there are several ways, You can generate taking the Max_Id + 1. What's the purpose of this Id in your Table?

Posted: Tue Dec 05, 2017 11:59 am
by Awais Dildar
No, I'm not looking for simple Id generation; its pretty much simple. I just wanted know the exact batch Id under which a job is being executed on daily basis for CDC.

Posted: Tue Dec 05, 2017 12:06 pm
by PaulVL
He is looking for the ID that ran the job.

Awais. Log in to your host, go to the command line and type whoami.

Posted: Tue Dec 05, 2017 12:14 pm
by sriven786
As mentioned, DataStage doesn't a feature called "Batch ID." In my previous project, we used to generate Job_Id whenever the Job Sequence starts and use log that id to Job Table to track the Job start and end and which job has inserted/updated/deleted along with the creation date and last updated date.

Posted: Tue Dec 05, 2017 2:19 pm
by UCDI
you can parse the current timestamp or job start timestamp out (remove : chars) and put it into the invocation id field which you can then see in the debugging tools and if you want you can store that in a column somewhere to tie it all together for debugging purposes.

there are other ways to do it ... we have a system that has a table where we store job name & run# and the data is stamped with run# as well

Posted: Tue Dec 05, 2017 2:58 pm
by chulett
I don't think "Batch ID" and "User ID" are equivalent here. :?

Can you define what your term means using other words, something other than simply "batch id"? Is this value something you're already seeing somewhere, say in a log entry and if so can you show it to us? I think it would go a long way towards lessening the confusion around what exactly it is that you need - an existing field you are aware of and need to capture, or something that currently does not exist that you need to generate. It does not seem to be the latter you are looking for but wanted to confirm.

Posted: Tue Dec 05, 2017 3:52 pm
by PaulVL
My bet is on "Batch ID" is the user id that is running the job in production, as opposed to some type of watermark value.

Posted: Tue Dec 05, 2017 4:24 pm
by chulett
We knows. :wink:

Posted: Wed Dec 06, 2017 1:30 am
by priyadarshikunal
A batch ID from what I have seen is an integer to track the records being inserted/updated during Job run. Mostly for audit purposes. And that needs to be generated before each job execution, a separate piece of code.

But only OP knows what he really wants.