Page 1 of 1

How to establish a connection to DB in Batch Jobs

Posted: Mon Apr 30, 2007 1:40 am
by laknar
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

Posted: Mon Apr 30, 2007 5:05 am
by ray.wurlod
Create a job the effects the insert, and run that job within the batch.

Re: How to establish a connection to DB in Batch Jobs

Posted: Mon Apr 30, 2007 7:17 am
by chulett
laknar wrote:How to execute a script in Batch Jobs
Or use DSExecute to run your script.

I declared a variable in First job like jobstarttime etc

Posted: Wed May 02, 2007 1:01 am
by laknar
* 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.

Posted: Wed May 02, 2007 6:25 am
by ray.wurlod
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.

Posted: Thu May 03, 2007 1:18 am
by laknar
i want to call all the variables in DB insert statement like

Jobstarttime
Joblasttime
Jobelapsedtime
Rundate

how to call that in batch jobs.

Posted: Thu May 03, 2007 3:14 am
by ray.wurlod
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.