Basic Routine Works, Calling Through Job Hangs

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
nishadkapadia
Charter Member
Charter Member
Posts: 47
Joined: Fri Mar 18, 2005 5:59 am

Basic Routine Works, Calling Through Job Hangs

Post by nishadkapadia »

Hi

I have written a simple routine to get Category for all the jobs. The Routine works fine when executed via manager.

On attaching a Routine Activity in Sequencer, the sequencer hangs but the routine does complete it's task.

The Routine Accepts no arguments and runs on the Entire Project.
It writes in a sequential file the Job Name and the Category.

Any Idea what am i missing here?

Thanks in advance,

The Routine Code is :-

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H
********************************
*Initialization of Variables
*
********************************
Ans = 0

* Write it to Sequential File the Link Details with the Enter Charachter.

  OpenSeq '/db2fs1/nishad/JobNamesAndCategory_temp.txt' to File_Handle Else ErrorCode = 1
  Seek File_Handle,0,2
  Else  ErrMsg = "Unable to position to end of File"

******************************
* Getting All Jobs within Current Project
*******************************

  JbLst = DSGetProjectInfo(DSJ.JOBLIST)
  TotalJbCnt = Dcount(JbLst,",")
  For JbCntr = 1 To TotalJbCnt
	JobName = Field(JbLst,',',JbCntr)
	Job_Handle = DSAttachJob(JobName,DSJ.ERRNONE)
                IF Not(Job_Handle) Then Continue
	Jb_Name = DSGetJobInfo(Job_Handle,DSJ.JOBNAME)  
      
      Shell = "UV" 
      Output = "" 
      ExitStatus = 0 
      Command = "SELECT CATEGORY FROM DS_JOBS WHERE NAME = '" : JobName : "'; "
      Call DSExecute(Shell, Command, Output, ExitStatus)
      Folder_Name = Ereplace(Ereplace(Ereplace(Ereplace(Output,@FM,''),'Category',''),'.',''),'1 records listed','')      
       WriteSeqF Jb_Name : '|' : Folder_Name  To File_Handle Else Call DSLogFatal("Cannot Open File","My Routine")    

ErrCd = DSDetachJob(Job_Handle)
Next JbCntr
CLOSESEQ File_Handle
Ans = ErrMsg
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

your SELECT is hanging because the job is still running and is holding a lock on this record. This will not happen if you change your job to do a HASHed file read instead of a SQL SELECT.
nishadkapadia
Charter Member
Charter Member
Posts: 47
Joined: Fri Mar 18, 2005 5:59 am

Post by nishadkapadia »

Thanks it's been resolved.
Post Reply