i think this behaviour and your code is correct, only the flag does not
change
if the falg does not change during execution, it returns an error
i the flag changes, it executes successfully
in this example the flag changes:
flag = 0
'Code to populat Flag with appropriate value
DTSGlobalVariables("counter").Value = _
DTSGlobalVariables("counter").Value + 1
Dim oPkg
If DTSGlobalVariables("counter").Value < 90 THEN
Set oPkg = DTSGlobalVariables.Parent
if DTSGlobalVariables("counter").Value = 56 then
flag = 1
end if
If Flag <> 1 Then
Main = DTSStepScriptResult_ExecuteTask
Else ' flag = 1
'Set oPkg = DTSGlobalVariables.Parent
'Set previous step status to waiting.
oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus = _
DTSStepExecStat_Waiting
'Do not execute task 2, step 1 will restart.
Main = DTSStepScriptResult_DontExecuteTask
End if
Else ' counter > 90
'Main = DTSTaskExecResult_Failure
End if
set oPkg = Nothing
End Function
'#####
' here the flag does not change, it retries 90 times, and then goes on to
the next task
flag = 0
'Code to populat Flag with appropriate value
DTSGlobalVariables("counter").Value = _
DTSGlobalVariables("counter").Value + 1
Dim oPkg
If DTSGlobalVariables("counter").Value < 90 THEN
Set oPkg = DTSGlobalVariables.Parent
If Flag <> 1 Then
Main = DTSStepScriptResult_ExecuteTask
Else ' flag = 1
'Set oPkg = DTSGlobalVariables.Parent
'Set previous step status to waiting.
oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus = _
DTSStepExecStat_Waiting
'Do not execute task 2, step 1 will restart.
Main = DTSStepScriptResult_DontExecuteTask
End if
Else ' counter > 90
Main = DTSStepScriptResult_ExecuteTask
'Main = DTSTaskExecResult_Failure
End if
set oPkg = Nothing
End Function
however, i do not really understand what you are trying to do. looping 90
times trough that should not really be a replacement for sleep.
if you want to make the system wait a few seconds, the easiest way is to
insert a SQL task inbetween the two activeX tasks you have and insert this
SQL statement:
WAITFOR DELAY '000:01:00'
each loop will then take one minute
perhaps you could describe in more detail what you are trying to do..
rgds
Leo
<GajanRaj (AT) gmail (DOT) com> wrote