Hi,
I would like to establish a connection to DB2 Db in Batch job
Iam trying to insert (Jobstarttime,jobendtime , job elapsed time and current date) into Db in the Batch job.
How to execute a script in Batch Jobs
How to establish a connection to DB in Batch Jobs
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: How to establish a connection to DB in Batch Jobs
Or use DSExecute to run your script.laknar wrote:How to execute a script in Batch Jobs
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
I declared a variable in First job like jobstarttime etc
* Setup A, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("A", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: A", "JobControl")
Abort
End
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
Jobname= DSGetJobInfo(hJob1, DSJ.JOBNAME)
Jobstarttime = DSGetJobInfo(hJob1, DSJ.JOBSTARTTIMESTAMP)
Jobendtime = DSGetJobInfo(hJob1, DSJ.JOBLASTTIMESTAMP)
Jobelapsedtime = DSGetJobInfo(hJob1, DSJ.JOBELAPSED)
Jobstatus=DSGetJobInfo(hJob1,DSJ_JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: A", "JobControl")
End
* Setup ReportJob, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("ReportJob", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: ReportJob", "JobControl")
Abort
End
ErrCode = DSSetDisableProjectHandler(hJob2, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob2, @FALSE)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: ReportJob", "JobControl")
End
I declared a variable in First job like jobstarttime etc,.
I want to call the variables into the next job in DB2 insert script.
how to call and how to insert job(A) report into table.
The above Batch i have shown you example.
Please help regarding this.
And how to run the job parallely in Batch jobs.
hJob1 = DSAttachJob("A", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: A", "JobControl")
Abort
End
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
Jobname= DSGetJobInfo(hJob1, DSJ.JOBNAME)
Jobstarttime = DSGetJobInfo(hJob1, DSJ.JOBSTARTTIMESTAMP)
Jobendtime = DSGetJobInfo(hJob1, DSJ.JOBLASTTIMESTAMP)
Jobelapsedtime = DSGetJobInfo(hJob1, DSJ.JOBELAPSED)
Jobstatus=DSGetJobInfo(hJob1,DSJ_JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: A", "JobControl")
End
* Setup ReportJob, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("ReportJob", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: ReportJob", "JobControl")
Abort
End
ErrCode = DSSetDisableProjectHandler(hJob2, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob2, @FALSE)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: ReportJob", "JobControl")
End
I declared a variable in First job like jobstarttime etc,.
I want to call the variables into the next job in DB2 insert script.
how to call and how to insert job(A) report into table.
The above Batch i have shown you example.
Please help regarding this.
And how to run the job parallely in Batch jobs.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Four calls to DSSetParam() will be needed before DSRunJob() is invoked to run ReportJob. DSJ_JOBSTATUS is not a valid DataStage constant; it needs to be DSJ.JOBSTATUS.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Create a job to insert the row. Pass the four values as job parameters. Generate one row.
Pass the parameters to the job from the batch, obtaining the values as described above.
Pass the parameters to the job from the batch, obtaining the values as described above.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.