I have a BASIC routine that calls DSAttachJob inside a loop. However, the code exits after the first iteration in the loop.
The loop itself works fine - commenting/removing the call to DSAttachJob shows that the loop is working correctly. As soon as I introduce DSAttachJob inside the loop, the loop terminates after the first iteration.
The overall objective of the script is to read files in a directory one at a time and upload the same.
BTW, I have other methods of doing the above and they work fine - I would like to try and find out as to why the DSAttachJob inside a loop is not working as expected.
Any ideas, suggestions, experiences appreciated.
Code: Select all
$INCLUDE DSINCLUDE JOBCONTROL.H
Equate RoutineName To 'seqfile_upd'
* Equate Arg1 To tb_name
Equate Arg1 To data_dir
Equate Arg2 To schema_dir
OPENPATH data_dir TO dirlist ELSE print "Error Opening Directory " data_dir
SELECT dirlist;
Loop
While READNEXT fname
tb_name = field (fname,".",1)
* PRINT tb_name ;
* PRINT fname ;
JobHandle = ''
JobHandle = DSAttachJob ("jb_data_upload", DSJ.ERRFATAL) ;
ErrCode = DSSetParam (JobHandle,"base_nm", tb_name)
ErrCode = DSSetParam (JobHandle,"data_dir", data_dir)
ErrCode = DSSetParam (JobHandle,"schema_dir", schema_dir)
ErrCode = DSRunJob(JobHandle, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(JobHandle)
Status = DSGetJobInfo(JobHandle, DSJ.JOBSTATUS)
JobEndTime = DSRTimestamp()
If Status = DSJS.RUNFAILED Then
Call DSLogWarn("Log WArn", RoutineName)
End
Else
Print "Job successfully executed"
Call DSLogInfo("Job successfully executed", RoutineName)
End
deterr = DSDetachJob (JobHandle)
Repeat