Handling Errors while reading file in Job Control

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
adarsh shrinagesh
Premium Member
Premium Member
Posts: 68
Joined: Sat Feb 05, 2005 4:59 am
Location: India

Handling Errors while reading file in Job Control

Post by adarsh shrinagesh »

Hi

Have been sweating it out wothout much success over checking for the presence of a file and if present reading a record through the Job control.


If CurrentStatus ='R' Then
OPENSEQ '/home/adarsh/':SequenceName:'.txt' TO FILE THEN
READSEQ LoadIdTimeStamp FROM FILE THEN TimeStampVal=Field(LoadIdTimeStamp,",",2) ELSE STOP
CLOSESEQ FILE
END
ELSE
Ans=0
END
End

I dont think I'm handling all error conditions - and this leads to a job control error while executing it from the sequence.
What I'm trying to do is
> Open file
If succesfull Read file and assign to a variable
else (file not present) carry on processing the rest of the code

..............................................

After this code we're calling a job which writes to the same file and sometime this hangs too

prbly bcoz we're not handliing locks

any ideas or code snippets ? I skimmed through the OpenSeqFile func Andrw had posted but If I'm not wrong thats for a file that's present for sure.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The OPENSEQ will take the ELSE branch if the file does not exist, and you shouldn't be using the STOP statement in a subroutine; this is designed for use in normal BASIC programs, you could replace it with "ELSE TimeStampVal = ''". This is most likely the cause for your job control error.

Sequential files are not locked the same way that tables/records are, so it is unlikely that you will get a job hanging because it is waiting to open a sequential file.
adarsh shrinagesh
Premium Member
Premium Member
Posts: 68
Joined: Sat Feb 05, 2005 4:59 am
Location: India

Post by adarsh shrinagesh »

ArndW wrote:[The OPENSEQ will take the ELSE branch if the file does not exist, and you shouldn't be using the STOP statement in a subroutine; this is designed for use in normal BASIC programs, you could replace it with "ELSE TimeStampVal = ''". This is most likely the cause for your job control error.

Sequential files are not locked the same way that tables/records are, so it is unlikely that you will get a job hanging because it is waiting to open a sequential file.
Hi - Thanks for the guidance - replaced STOP ... it seems the job that was being called was not in a runnable state too ... anyway have rectified things and they are now on track
Post Reply