I have a code for running a snapshot job. It enters an endless loop. and i do not understand that loop part !
...
...
Set oJob = m_oSqlServer.JobServer.GetJobByID(sSnapshotJobID, True)
' ------------------------------------------------
' Activating the Snapshot Job
' ------------------------------------------------
With oJob
.Enabled = True
.JobSchedules(1).Schedule.FrequencySubDay = SQLDMOFreqSub_Once
.PurgeHistory
.Invoke
.Enabled = False
End With
'----------------------------
' Filtering History Messages
'----------------------------
Set oJobHistoryFilter = m_oSqlServer.JobServer.JobHistoryFilter
With oJobHistoryFilter
.JobID = sSnapshotJobID
.StartRunTime = oJob.LastRunTime
.StartRunDate = oJob.LastRunDate
.OldestFirst = False
End With
With oJob
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
'++++++++++++++++++++++++++++++++
' FIRST UNKNOWN LOOP.....
'++++++++++++++++++++++++++++++++
Do While oQueryResults.Rows < 2
Pause 2000
Set oQueryResults = Nothing
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
Loop
'++++++++++++++++++++++++++++++++
' SECOND LOOP.....
'++++++++++++++++++++++++++++++++
Do While Timer < start + vTimeOut And _
InStr(oQueryResults.GetColumnString(2, 8), "1 article" = 0
Set oQueryResults = Nothing
Pause 20000
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
Loop
End With
- IS THIS LAST 2 LOOPS IS IN PLACE ??
- CAN ANYONE UNDERSTAND THE NEED FOR THE FIRST LOOP ?
sometimes it get stuck over there with .rows=0 (once a day)
I DO UNDERSTAND THAT IM LOOKING FOR "1 article was created" IN THE SECOND LOOP....
WHAT IS THE WAY OF CHECKING IF THE JOB WAS EXECUTED AND DONE ???
Thanx,
Mooki
...
...
Set oJob = m_oSqlServer.JobServer.GetJobByID(sSnapshotJobID, True)
' ------------------------------------------------
' Activating the Snapshot Job
' ------------------------------------------------
With oJob
.Enabled = True
.JobSchedules(1).Schedule.FrequencySubDay = SQLDMOFreqSub_Once
.PurgeHistory
.Invoke
.Enabled = False
End With
'----------------------------
' Filtering History Messages
'----------------------------
Set oJobHistoryFilter = m_oSqlServer.JobServer.JobHistoryFilter
With oJobHistoryFilter
.JobID = sSnapshotJobID
.StartRunTime = oJob.LastRunTime
.StartRunDate = oJob.LastRunDate
.OldestFirst = False
End With
With oJob
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
'++++++++++++++++++++++++++++++++
' FIRST UNKNOWN LOOP.....
'++++++++++++++++++++++++++++++++
Do While oQueryResults.Rows < 2
Pause 2000
Set oQueryResults = Nothing
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
Loop
'++++++++++++++++++++++++++++++++
' SECOND LOOP.....
'++++++++++++++++++++++++++++++++
Do While Timer < start + vTimeOut And _
InStr(oQueryResults.GetColumnString(2, 8), "1 article" = 0
Set oQueryResults = Nothing
Pause 20000
Set oQueryResults = .EnumHistory(oJobHistoryFilter)
Loop
End With
- IS THIS LAST 2 LOOPS IS IN PLACE ??
- CAN ANYONE UNDERSTAND THE NEED FOR THE FIRST LOOP ?
sometimes it get stuck over there with .rows=0 (once a day)
I DO UNDERSTAND THAT IM LOOKING FOR "1 article was created" IN THE SECOND LOOP....
WHAT IS THE WAY OF CHECKING IF THE JOB WAS EXECUTED AND DONE ???
Thanx,
Mooki