dbTalk Databases Forums  

Looping in MS SQL 2000 DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Looping in MS SQL 2000 DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
GajanRaj@gmail.com
 
Posts: n/a

Default Looping in MS SQL 2000 DTS - 07-05-2005 , 05:14 AM






Hi

I am working on a DTS package which Checks a Flag and if required value
is not returned waits for a specified period before trying again (max
90 times). I do not want to use VBS Sleep command as I will have to
refer to an external .vbs file.

When I use DTSStepScriptResult_DontExecuteTask the package is always
returning "Task returned failure on execution". The code I am using is
based on an MSDN example and I can't see what I am doing wrong. Any
suggestions would be appreciated.

My Code:

'Code to populat Flag with appropriate value

DTSGlobalVariables("counter").Value = _
DTSGlobalVariables("counter").Value + 1

If DTSGlobalVariables("counter").Value < 90 THEN
Set oPkg = DTSGlobalVariables.Parent

If Flag <> 1 Then
Main = DTSStepScriptResult_ExecuteTask

Else
Set oPkg = DTSGlobalVariables.Parent
'Set previous step status to waiting.
oPkg.Steps("DTSStep_DTSActiveScriptTask_1").Execut ionStatus = _
DTSStepExecStat_Waiting

Set oPkg = Nothing
'Do not execute task 2, step 1 will restart.
Main = DTSStepScriptResult_DontExecuteTask

End if

Else

Main = DTSTaskExecResult_Failure

End if

set oPkg = Nothing

End Function


Reply With Quote
  #2  
Old   
Leo Matter
 
Posts: n/a

Default Re: Looping in MS SQL 2000 DTS - 07-16-2005 , 10:11 AM






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

Quote:
Any suggetions?




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.