Hi guys,
Stange problem that I'm facing, when running the below code is inside system task scheduled to run every 5 mins it execute till check("gg")=3, stops at While Rs.Next() and you might thing that's because there no records but yest there records because If I run the same task from the terminal it run fine and process all records, also if I copy the whole code into a classMethod and run the classmethod from the terminal it run fine as well, its only if it runs through the scheduling process or by click run in SMP that runs till check point 3 and doesn't go any further !?
s ^check("gg",0)=1_"|"_$J_"|"_$ZU(61)_"|"_$zt($P($h,",",2))
$$$DebugLog("GetJobs","getJobs start onTask "_$G(^STOPGNJ, 0),"")
Quit:$G(^STOPGNJ, 0) $$$OK
Set ^STOPGNJ=1
s ^check("gg")=1
try{
Set SQL = "Select top 1000 tl.ID,tl.SensorId,tl.SensorType, tl.Loc as Loc from "_
" MSDS_Common.ScheduleTaskList tl"_
" left join MSDS_Common.ScheduleTaskListHistory th on th.ScheduleTask = tl.ID"_
" where %Internal(tl.ScheduledTask)='O' and %Internal(tl.Status)='A' and (%Internal(tl.State)='S' or %Internal(tl.State)='Q')"_
" group by tl.id "_
" order by tl.id desc"
s ^check("gg2018")=SQL
s ^check("gg")=2
Set Rs=##class(%ResultSet).%New()
Do Rs.Prepare(SQL)
Do Rs.Execute()
s ^check("gg")=3
While Rs.Next(){
s ^check("gg")=4
Set ID=Rs.Get("ID")
Set SensorTag=Rs.Get("SensorId")
Set SensorType=Rs.Get("SensorType")
Continue:$G(ID,"")="" Continue:$ZCVT(SensorType,"U")="TPROBE" Continue:$G(^StoreJob(ID),"")'="" //Continue:TryCount>=5 //&SQL(SELECT count(*) Set ^StoreJob(ID)=SensorTag_"||"_$zdt($zts,3)
}
}
Catch
{
$$$DebugLog("PushNQL","Exception happened in getjobs task: "_$ZERROR,"")
S Stream=##class(%GlobalCharacterStream).%New()
D Stream.WriteLine("Something went wrong, error in Get_New_Jobs task, Please have a look.")
D Stream.WriteLine("Error Message : "_$ZERROR)
D Stream.WriteLine("Error Code : "_$ECODE)
D Stream.WriteLine("")
D Stream.WriteLine("Thanks,")
D Stream.WriteLine("SX3 Support")
S MailStatus=##class(SX3.Production.HTTP.GetRequest).SendErrorMail(Stream)
Set ^STOPGNJ=0 } Set ^STOPGNJ=0
Thanks