How do I store job status information in table?

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

How do I store job status information in table?

Post by adityavarma »

Hi All,

I have a requirement where in i need to update a table, if the job is failed or success a table need to be updated with the below fields to be populated.
JOB_SEQ_START_DT
JOB_SEQ_END_DT
DURATION
STATUS (OK/KO)

Split job --> Tranfm job --> Load job.

Can you please suggest me on how to proceed on this?
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Do you need to insert records in the table after each job?

Not a bad idea, but you need to execute a routine after each job. As after job sub-routine or routine in the sequence. You can manipulate the code found at Kim Duke's website as per your needs.

Can you opt for inserting all entries after all the jobs finishes its execution?

In this case Just use Kim Duke's ETLStats which gives you almost all the details you may need to log about the jobs (No need to reinvent the wheels). In this case also, you may need to manipulate it as per your needs.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

Exception activity-------> Job Activity(Status Update Job in Table)........> Terminator Activity for Failed Jobs.


For successfull completion. Call Job Activity(Status Update Job in Table) at end of the activity.

so your design will be like below.


Job Activity(Actual Job)--->Job Activity(Status Update Job in Table)
Exception activity---> Job Activity(Status Update Job in Table)..>Terminator Activity
Regards
LakNar
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

We are thinking of implementing a routine for each sequence, once it is failed the table will be updated and if it is successful, at the end a routine to update the status ok.

@kunal,
We could not find any routine corresponding to this in the duke's website.

Can you please suggest us on this.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ETL Stats is in the Tips & Tricks section of Kim's site.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Click on icon below my sig.
Mamu Kim
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

Thanks duke,

I am able to go through your site, but i am not able to find out the correct routine which is required for my requirement.

I am new to routines and may be this is one reason i am not able to find it out.

Thinking of writing a routine, but i am stuck in how to connect to oracle database to update the status in the table and get the start time and end time.

i am very much new to routines, i just tried one basic routine, but not able to compile it.

Jobstat = DSGetJobInfo(jobname, DSJ.JOBSTATUS)
If Jobstat = DSJS.RUNFAILED
then
Ans = 1

Jobstat = DSGetJobInfo(jobname, DSJ.JOBSTATUS)
If Jobstat = DSJS.RUNWARN
then
Ans = 1

Jobstat = DSGetJobInfo(jobname, DSJ.JOBSTATUS)
If Jobstat = DSJS.RUNOK
then
Ans = 0


IF ANS = 1
then
sqlplus -l UNAME/PWD@DATABASE

INSERT statement

exit;

IF ANS = 0
then
sqlplus -l UNAME/PWD@DATABASE

INSERT statement

exit;


Can you please suggest me on this
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The "IF-THEN-ELSE" construct functions in that if you have the format "IF (condition) THEN (statement)" then only one statement is executed and you don't need an "END", but your format has the "THEN" at the end of the line, which means that all the statements until the next matching END are part of the condition. Your compile error is due to that. Change your lines to read "... THEN Ans = 1"
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I just read the rest of the program. It won't work at all, there are sevearl problems with it, including that DataStage BASIC has no idea of what commands such as "sqlplus" are...

Here is a modified version:

Code: Select all

   JobHandle = DSAttachJob(jobname,DSJ.ERRNONE)
   Jobstat = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS) 
   IF Jobstat = DSJS.RUNOK 
   THEN
      Ans = 0
      Script = '/path/to/script.sh'
   END
   ELSE
      If Jobstat = DSJS.RUNFAILED OR Jobstat = DSJS.RUNWARN THEN Ans = 1
      Script='/path/to/otherscript.sh'
   END
   EXECUTE 'SH -c "':Script:'"' CAPTURING ScreenIO RETURNING ErrorCode
   Dummy = DSDetachJob(JobHandle)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A bit obscure to introduce the SH verb, Arnd. A call to DSExecute can go directly to the operating system shell.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You are correct, Ray. Just force of habit from ye olde UniVerse days which had no DSExecute() call.
adityavarma
Premium Member
Premium Member
Posts: 104
Joined: Thu Jul 12, 2007 11:32 pm
Location: Canada

Post by adityavarma »

Instead of using routine for the above requirement, can we use a shell script, i thought of doing but

dsjob -report <Projectname> <JobName> BASIC > log.txt


**************************************************
STATUS REPORT FOR JOB: <JobName>
Generated: 2010-06-29 10:06:45
Job start time=2010-06-29 08:42:38
Job end time=2010-06-29 08:42:43
Job elapsed time=00:00:05
Job status=1 (Finished OK)

The above is the output when i executed the dsjob command

i am not sure how to pass the project and jobname to the shell script.
and take these details and update the table.

Please suggest me on this.
laknar
Participant
Posts: 162
Joined: Thu Apr 26, 2007 5:59 am
Location: Chennai

Post by laknar »

The project name and Jobname can be passed through DS Macros.

Execute the script using Execute Command Activity Stage and Pass the required parameters.

Derive the project name and Jobname prior to the Execute Command Activity.
Regards
LakNar
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

It is not a routine. It is a job. The job takes dsjob -report XML and outputs it to a JobName.xml file in the before routine. Next it processes this into 3 tables ETL_JOB_HIST, ETL_ROW_HIST and ETL_PARAM_HIST. The DDL is included.
Mamu Kim
varaprasad
Premium Member
Premium Member
Posts: 34
Joined: Fri May 16, 2008 6:24 am

Post by varaprasad »

One way is, write a shell script to update your Oracle table and call that script using the DSExecute() function. Pass the captured values as parameters to this call.
Post Reply